Elasticsearch匹配多个字段

sal*_*hed 3 python elasticsearch

我最近elasticsearch在网站上使用.场景是,我必须搜索一个字符串field.所以,如果field命名为title那么我的搜索查询是,

"query" :{"match": {"title": my_query_string}}.
Run Code Online (Sandbox Code Playgroud)

但现在我需要添加另一个field.让我们说吧category.所以我需要找到我的字符串中的匹配符号category:some_category和哪些符号title:my_query_string我试过了multi_match.但它并没有给我我想要的结果.我现在正在调查query filter.但有没有办法在我的match查询中添加这样的标准中的两个字段?

Kri*_*ons 6

GET indice/_search
{
  "query": {
    "bool": {
      "should": [
        {
          "match": {
            "title": "title"
          }
        },
        {
          "match": {
            "category": "category"
          }
        }
      ]
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

更换shouldmust,如果需要的话.