opendistro-for-elasticsearch / k-NN

🆕 A machine learning plugin which supports an approximate k-NN search algorithm for Open Distro.
https://opendistro.github.io/
Apache License 2.0
277 stars 55 forks source link

PostingsFormat Fix for odfe 1.9 #250

Closed vamshin closed 4 years ago

vamshin commented 4 years ago

Issue #, if available: https://github.com/opendistro-for-elasticsearch/k-NN/issues/227

Description of changes: https://github.com/opendistro-for-elasticsearch/k-NN/pull/236

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

vamshin commented 4 years ago

Manually verified suggest Field to check PostingsFormat fix

curl -X PUT "localhost:9200/music?pretty" -H 'Content-Type: application/json' -d'

{ "settings": { "index": { "knn": true } }, "mappings": { "properties": { "suggest": { "type": "completion" } } } } '

curl -X POST "localhost:9200/music/_doc/1?refresh=true" -H 'Content-Type: application/json' -d' { "suggest" : { "input": [ "Nevermind", "Nirvana" ], "weight" : 34 } } '

curl -X POST "localhost:9200/music/_search?pretty" -H 'Content-Type: application/json' -d' { "suggest": { "song-suggest": { "prefix": "nir", "completion": { "field": "suggest" } } } } '

Output:-

{ "took" : 92, "timed_out" : false, "_shards" : { "total" : 1, "successful" : 1, "skipped" : 0, "failed" : 0 }, "hits" : { "total" : { "value" : 0, "relation" : "eq" }, "max_score" : null, "hits" : [ ] }, "suggest" : { "song-suggest" : [ { "text" : "nir", "offset" : 0, "length" : 3, "options" : [ { "text" : "Nirvana", "_index" : "music", "_type" : "_doc", "_id" : "1", "_score" : 34.0, "_source" : { "suggest" : { "input" : [ "Nevermind", "Nirvana" ], "weight" : 34 } } } ] } ] } }