forked from ongr-io/ElasticsearchDSL
-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Knn Search Support #27
Comments
Nobody yet as I know did yet implement knn search or vector types. If somebody want to contribute it feel free, currently we have not yet planned it. |
Thanks for the quick response! I'm interested in giving it a try and attempting to implement knn search support for the library. I hope I can implement it in short time. 🤗 |
Implemented a solution and here an example usage: <?php
use Elastic\Elasticsearch\ClientBuilder;
use ONGR\ElasticsearchDSL\Knn\Knn;
use ONGR\ElasticsearchDSL\Query\MatchAllQuery;
include __DIR__ . '/../vendor/autoload.php';
$builder = ClientBuilder::create();
$builder->setElasticCloudId("....");
$builder->setApiKey('....');
$client = $builder->build();
$knn = new Knn(
'my_vector',
[0.5, 10, 8],
10,
100,
);
$matchAll = new MatchAllQuery();
$knn->setFilter($matchAll);
$search = new ONGR\ElasticsearchDSL\Search();
$search->addKnn($knn);
$params = [
'index' => 'my-index',
'body' => $search->toArray(),
];
$response = $client->search($params);
var_dump($response->asArray()); @alexander-schranz what do you think? |
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Do we have a plan to add support for Knn Search, or is it possible with this library? I would like to hear your opinions.
ping @alexander-schranz
The text was updated successfully, but these errors were encountered: