es之suggest
生活随笔
收集整理的這篇文章主要介紹了
es之suggest
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
suggest根據關鍵字從指定的索引中推進和關鍵詞拼寫相近的詞
GET kibana_sample_data_ecommerce/_search {"suggest": {"term-suggestion": {"text": "ddie","term": {"field": "customer_first_name","prefix_length":0,"suggest_mode":"always"}}} }phrase suggest
GET suggest_index/_search {"suggest": {"term-suggestion": {"text": "love this","phrase": {"field": "region_name","max_errors":10,"confidence":0}}} }自動補全,僅支持前綴補全
自動補全的要在mapping中設置。
PUT complete_index/ {"mappings": {"properties": {"title":{"type": "completion"}}} }PUT complete_index/_doc/1 {"title":"testgood" }GET complete_index/_search {"suggest": {"YOUR_SUGGESTION": {"text": "te","completion": {"field": "title"}}} }上下文自動補全,僅支持前綴補全
PUT complete_index2/ {"mappings": {"properties": {"title":{"type": "completion","contexts":[{"type":"category","name":"title_cate"}]}}} }POST complete_index2/_doc/ {"rel_title":"i love this moive","title":{"input":"love this movie","contexts":{"title_cate":"moive"}} }POST complete_index2/_doc/ {"rel_title":"i love this coffie","title":{"input":"love this coffie","contexts":{"title_cate":"coffie"}} }GET complete_index2/_search {"suggest": {"YOUR_SUGGESTION": {"prefix": "lov","completion": {"field": "title","contexts":{"title_cate":"coffie"}}}} }總結
以上是生活随笔為你收集整理的es之suggest的全部內容,希望文章能夠幫你解決所遇到的問題。