小编vij*_*ani的帖子

过滤'_index'与搜索多个索引查询弹性搜索中的'_type'相同

我有两个索引index1index2,并且在弹性搜索中都有两个类型type1type2具有相同的名称.(请假设我们背后有有效的商业原因)

我想搜索index1 - type1index2 -type2

这是我的查询

POST _search
{
 "query": {
    "indices": {
      "indices": ["index1","index2"],      
      "query": {
        "filtered":{  
         "query":{
       "multi_match": {
           "query": "test",
           "type": "cross_fields",
           "fields": ["_all"]         
       }

        },
         "filter":{  
            "or":{  
               "filters":[  
                  {  
                     "terms":{ 
                                "_index":["index1"], // how can i make this work?
                               "_type": ["type1"]
                     }                      
                  },
                  {  
                     "terms":{ 
                               "_index":["index2"], // how can i make this work?
                               "_type": ["type2"]
                     }                      
                  }
               ]
            }
         }
      }
      },
      "no_match_query":"none"
    }
  }
 }
Run Code Online (Sandbox Code Playgroud)

json elasticsearch

0
推荐指数
1
解决办法
1546
查看次数

标签 统计

elasticsearch ×1

json ×1