Created
May 1, 2018 15:59
-
-
Save p5f8/fc81d23bf91ee9187e2cd47febf7271b to your computer and use it in GitHub Desktop.
Revisions
-
p5f8 created this gist
May 1, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,170 @@ # https://www.elastic.co/videos/using-the-completion-suggester # https://stackoverflow.com/questions/28268418/elasticsearch-completion-suggester-on-multifield-with-different-weighting # ALL tests using elasticsearch 6.2.4 and kibana 6.2.4 DELETE /newclient PUT /newclient { "mappings": { "_doc" : { "properties": { "name" : { "type": "text" }, "name_suggest" : { "type": "completion" } } } } } GET newclient/_doc/_search # using fuzzy POST /newproduct/_search { "suggest": { "product_suggestion": { "text": "ipone", "completion": { "field": "name_suggest", "fuzzy" : { "fuzziness": 1 } } } } } PUT /newclient/_doc/1 { "name": "Pablo Fernando da Silva", "name_suggest": { "input": [ "Pablo Fernando da Silva", "Pablo Fernando", "Pablo" ] }, "output": "Pablo Fernando da Silva" } PUT /newclient/_doc/2 { "name": "Páblo Fernando da Silva", "name_suggest": { "input": [ "Páblo Fernando da Silva", "Páblo Fernando", "Páblo", "Pablo" ] }, "output": "Páblo Fernando da Silva" } PUT /newclient/_doc/3 { "name": "Almerita Maria da Silva", "name_suggest": { "input": [ "Almerita Maria da Silva", "Almerita Maria", "Almerita" ] }, "output": "Almerita Maria da Silva" } PUT /newclient/_doc/4 { "name": "Álmerita Maria da Silva", "name_suggest": { "input": [ "Álmerita Maria da Silva", "Álmerita Maria", "Álmerita", "Almerita" ] }, "output": "Álmerita Maria da Silva" } PUT /newclient/_doc/5 { "name": "Pabllo Vittar", "name_suggest": { "input": [ "Pabllo Vittar", "Pabllo", "Pablo", "Vitar", "Vittar" ] }, "output": "Pabllo Vittar" } # great results POST /newclient/_search { "suggest": { "product_suggestion": { "text": "pa", "completion": { "field": "name_suggest" } } } } # using fuzzy POST /newclient/_search { "suggest": { "product_suggestion": { "text": "pa", "completion": { "field": "name_suggest", "fuzzy" : { "fuzziness": 1 } } } } } # using fuzzy POST /newproduct/_search { "suggest": { "product_suggestion": { "text": "ipxon", "completion": { "field": "name_suggest", "fuzzy" : { "fuzziness": 2 } } } } } # using fuzzy POST /newclient/_search { "suggest": { "product_suggestion": { "text": "p", "completion": { "field": "name_suggest", "fuzzy" : { "fuzziness": 2 } } } } }