ElasticSearch fuzzy模糊查询(英文检索)
生活随笔
收集整理的這篇文章主要介紹了
ElasticSearch fuzzy模糊查询(英文检索)
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
?fuzzy實現(xiàn)模糊查詢
value:查詢的關鍵字
boost:查詢的權值,默認值是1.0
min_similarity:設置匹配的最小相似度,默認值為0.5, 對于字符串,取值為0-1(包括0和1);對于數(shù)值,取值可能大于1;對于日期型取值為1d,1m等,1d就代表1天
prefix_length:指明區(qū)分詞項的共同前綴長度,默認是0
max_expansions:查詢中的詞項可以擴展的數(shù)目,默認可以無限大
GET /ib3/user/ search { "queny":{ "fuzy*:{ *interests": "chagge* }}}
GET /ib3/user/_ search { "query":{ "fuzzy*: { "interests":{ "value*: "chagge" }}}
?
#下面可以明顯查詢條件寫錯了,但是我們使用模糊查詢就可以查詢出來,模糊查詢很簡單?
#fuzzy模糊查詢 GET /lib3/user/_search {"query": {"fuzzy": {"name": "zholiu"}} } {"took" : 587,"timed_out" : false,"_shards" : {"total" : 5,"successful" : 5,"skipped" : 0,"failed" : 0},"hits" : {"total" : 1,"max_score" : 0.23973508,"hits" : [{"_index" : "lib3","_type" : "user","_id" : "1","_score" : 0.23973508,"_source" : {"name" : "zhaoliu","address" : "hei long jiang sheng tie ling shi","age" : 50,"birthday" : "1970-12-12","interests" : "xi buan hejiu, duanlian, lvyou"}}]} }?
GET /lib3/user/_search {"query": {"fuzzy": {"interests": {"value": "chagge"}}} } {"took" : 35,"timed_out" : false,"_shards" : {"total" : 5,"successful" : 5,"skipped" : 0,"failed" : 0},"hits" : {"total" : 3,"max_score" : 0.57762265,"hits" : [{"_index" : "lib3","_type" : "user","_id" : "2","_score" : 0.57762265,"_source" : {"name" : "zhaoming","address" : "bei jing hai dian qu qing he zhen","age" : 20,"birthday" : "1998-10-12","interests" : "xi huan hejiu, duanlian, changge"}},{"_index" : "lib3","_type" : "user","_id" : "5","_score" : 0.23973508,"_source" : {"name" : "zhangsan","address" : "bei jing chao yang qu","age" : 29,"birthday" : "1988-10-12","interests" : "xi huan tingyinyue , changge , tiaowu"}},{"_index" : "lib3","_type" : "user","_id" : "3","_score" : 0.23973508,"_source" : {"name" : "lisi","address" : "bei jing hai dian qu qing he zhen","age" : 23,"birthday" : "1998-10-12","interests" : "xi huan hejiu,duanlian, changge"}}]} }?
總結
以上是生活随笔為你收集整理的ElasticSearch fuzzy模糊查询(英文检索)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 一个含n个顶点和e条弧的有向图以邻接矩阵
- 下一篇: 手机qpython3安装库_iPhone