使用query_string时,Elasticsearch会提升字段

时间:2014-07-02 03:51:19

标签: elasticsearch

是否可以在此表单的查询中提升字段?

   "query": {
      "filtered": {
         "query": {
            "query_string": {
               "query": "the user's search query",
               "fields": ["name", "description"],
               "default_operator": "OR"
            }
         },
         "filter": {...}
      }
   }

1 个答案:

答案 0 :(得分:12)

是的,只需在字段(名称^ 5)上添加boost语法,例如:

"query": {
   "filtered": {
      "query": {
         "query_string": {
            "query": "the user's search query",
            "fields": ["name^5", "description"],
            "default_operator": "OR"
         }
      },
      "filter": {...}
   }
}

在文档中似乎很清楚: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html