我有两个指标指数1和索引2两者有两种类型TYPE1和TYPE2与弹性搜索同名(请假设我们有它背后有效的商业理由)过滤器“_index”同样的方法,在多个索引查询弹性搜搜“_type”
我想搜索索引1 - TYPE1和索引2 -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"
}
}
}
你能解释一下你面临的问题吗?你的查询对我来说工作正常,我有相同的场景多个相同类型的索引。 – Roopendra 2014-10-01 04:54:46
嗨Roopendra,当我执行上面的查询时,它返回的结果来自index1-> type2和index2-> type1,我不想要。我只需要index1-> type1和index2-> type2。我相信那是因为它不是在“_index”字段上过滤术语。希望是有道理的。非常感谢 – 2014-10-01 05:26:37