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

Fix PostingsFormat in KNN Codec (#236) #248

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.

codecov[bot] commented 4 years ago

Codecov Report

Merging #248 into opendistro-1.10 will decrease coverage by 0.10%. The diff coverage is 100.00%.

Impacted file tree graph

@@                  Coverage Diff                  @@
##             opendistro-1.10     #248      +/-   ##
=====================================================
- Coverage              77.87%   77.76%   -0.11%     
- Complexity               308      311       +3     
=====================================================
  Files                     50       50              
  Lines                   1184     1192       +8     
  Branches                 100      100              
=====================================================
+ Hits                     922      927       +5     
- Misses                   218      221       +3     
  Partials                  44       44              
Impacted Files Coverage Δ Complexity Δ
...csearch/knn/index/codec/KNN86Codec/KNN86Codec.java 92.00% <100.00%> (+2.00%) 14.00 <4.00> (+2.00)
...roforelasticsearch/knn/plugin/KNNCodecService.java 75.00% <100.00%> (+8.33%) 3.00 <1.00> (+1.00)
...oforelasticsearch/knn/plugin/KNNEngineFactory.java 100.00% <100.00%> (ø) 3.00 <2.00> (ø)
...istroforelasticsearch/knn/index/KNNIndexCache.java 92.30% <0.00%> (-2.89%) 35.00% <0.00%> (ø%)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update ed9c7dc...680d821. Read the comment docs.

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 } } } ] } ] } }