2017-05-08 117 views
0

我有这样的JSON:指定字段进行搜索到elasticsearch

body: { 
    "sort" : queryBody.sort, 
    "query": { 
     "bool": { 
      "must": [ 
       {"query_string": { "query": '"mystring"' } } 
      ], 
      "filter": { 
       query_string: { query: '"mystring"' } } search-filter [{"term":{"accessType":1}}] 
      } 
     } 
    } 
}  

此JSON似乎在文档中的所有领域内进行搜索。如何根据当前的json指定我要搜索的确切字段? 我已经看到资源解释你应该添加“字段” - 阵列。但我找不到像我的结构,它有模式

query.bool.must.query_string 

所以我真的不明白在哪里放置fields-array。

回答

1

你非常接近。您需要添加fields阵列。请尝试以下查询:

{ 
    "query": { 
    "bool": { 
    "must": [ 
     { 
      "query_string": { 
      "fields": [ 
       "field1" , 
       "field2" 
      ], 
       "query": "this AND that OR thus" 
      } 
      } 
     ] 
     } 
    } 
} 
相关问题