多索引搜索(自动完成)

阿里雷扎·巴希里

我有四个索引,分别是城市,地区,国家和酒店,它们有一个共同的名称,我想搜索这些索引并获得用于自动完成的结果。另外,由于在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"
      }
    }
  }
}
阿尔基斯·卡洛格里斯(Alkis Kalogeris)

您可以使用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] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章