为什么Termslookup 不适用于别名?

问题描述 投票:0回答:1

我有这个 termlookup 查询获取(而不是编写)文档:

{
  "query": {
    "terms": {
        "name" : {
            "index" : "people",
            "id" : "2",
            "path" : "name"
        }
    }
  }
}

当“people”与多个索引关联时,我收到此错误:

别名 [people] 有多个与之关联的索引 [people1, people-archive],无法执行单个索引操作

那么如果我想在多个索引中搜索是不可能的吗? 或者我应该以某种方式指定索引数组而不是别名?

elasticsearch
1个回答
0
投票

您只能定义索引或仅与

terms lookup
查询中的一个索引关联的别名。如果失败,请尝试以下 API 调用
terms lookup query
 也会失败。

GET people/_doc/2

那么如果我想在多个索引中搜索是不可能的吗?或者我应该以某种方式指定索引数组而不是别名?

是的,您可以搜索多个索引,如下所示。

GET index1,index2/_search

GET index*/_search

但是您不能对多个索引使用某些特定查询,例如

terms lookup
,因为它应该从一个特定文档获取值。

如果您想像示例中那样使用

terms lookup
查询,您应该将查询一一发送到索引。

https://www.elastic.co/guide/en/elasticsearch/reference/7.10/query-dsl-terms-query.html#query-dsl-terms-lookup

© www.soinside.com 2019 - 2024. All rights reserved.