当前位置:网站首页>DSL realizes automatic completion query

DSL realizes automatic completion query

2022-07-19 06:35:00 Its natural happy clothes

elasticsearch Provides Completion Suggester Query to achieve automatic completion function . The query matches the entry that begins with the user's input and returns . In order to improve the efficiency of complement query , There are some constraints on the types of fields in the document :

•  The fields participating in the completion query must be completion type .

       •  The content of the field is generally formed by multiple entries used to complete Array .

The query syntax is as follows :

//  Automatic completion query 
GET /test/_search
{
  "suggest": {
    "title_suggest": {
      "text": "s", //  keyword 
      "completion": {
        "field": "title", //  Complete the fields of the query 
        "skip_duplicates": true, //  Skip the repetitive 
        "size": 10 //  Before acquisition 10 Bar result 
      }
    }
  }
}

test :

 

原网站

版权声明
本文为[Its natural happy clothes]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/200/202207170509129817.html