【发布时间】:2014-10-01 02:52:54
【问题描述】:
我有两个索引 index1 和 index2 并且都有两个类型 type1 和 type2 同名弹性搜索。(请假设我们有正当的商业理由)
我想搜索 index1 - type1 和 index2 -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,当我执行上面的查询时,它会返回我不想要的 index1->type2 和 index2->type1 的结果。我只想要 index1->type1 和 index2->type2。我相信这是因为它没有过滤“_index”字段上的术语。希望这是有道理的。非常感谢
标签: json elasticsearch