我有四个索引,分别是城市,地区,国家和酒店,它们有一个共同的名称,我想搜索这些索引并获得用于自动完成的结果。另外,由于在Elasticsearch 6.x中每个索引更改一个文档,因此我无法使用Logstash和reindex API中的JDBC输入创建具有单个索引的多类型。
GET /hotels/hotels/_search
{
"query": {
"match": {
"name": {
"query": "term",
"operator": "and"
}
}
}
}
我想对多索引情况做同样的事情。以下无效:
GET hotels,cities,countries,regions/_search
{
"query": {
"match": {
"name": {
"query": "term",
"operator": "and"
}
}
}
}
您可以使用Multi Search API。这样,您可以对不同的索引提供多个查询。例如:
GET _msearch
{"index" : "hotels"}
{ "query": { "match": { "name": { "query": "term", "operator": "and" } } } }
{"index" : "cities"}
{ "query": { "match": { "name": { "query": "term", "operator": "and" } } } }
{"index" : "countries"}
{ "query": { "match": { "name": { "query": "term", "operator": "and" } } } }
{"index" : "regions"}
{ "query": { "match": { "name": { "query": "term", "operator": "and" } } } }
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句