【问题标题】:Elasticsearch Completion Suggester ignores Index parameter and returns results for multiple indicesElasticsearch Completion Suggester 忽略 Index 参数并返回多个索引的结果
【发布时间】:2020-09-05 17:08:00
【问题描述】:

我正在使用 Elastic 的 PHP 实现来使用这样的 Completion Suggester:

    $params_organisations = [
        'index' => $this->organisation_index,
        'body' => [
            "suggest" => [
                "suggestions" => [
                    'prefix' => $request->q,
                    "completion" => [
                        "field" => "suggest1",
                        "fuzzy" => ["fuzziness" => 0],
                        "skip_duplicates" => "false",
                        "size" => 7
                    ]
                ]
            ]
        ]
    ];

但是,响应也包含其他索引:

suggest: {suggestions: Array(1)}
timed_out: false
took: 8
_shards:
failed: 3
failures: Array(3)
0:
index: ".kibana_1"
node: "xxxxxxxxx"
reason: {type: "illegal_argument_exception", reason: "no mapping found for field [suggest1]"}

我担心这可能会影响性能,因为其他一些索引确实包含 suggest1, 字段并且它们被搜索并返回结果。我没有更改名称,有时我想以类似的方式处理建议字段,但是跨索引具有相同的建议类型字段名称是否有问题?

或者有没有办法更明确地定义索引?我也尝试将索引名称附加到端点,但结果相同。我在 PHP 实现中找到了一个明确的建议端点,但它似乎已被弃用?非常感谢任何帮助!

【问题讨论】:

  • 这是在什么版本的弹性上运行的?
  • 我们使用的是 6.8 版
  • “organisation_index”是索引还是别名?
  • 这是一个来自配置参数(来自 .env)的字符串映射到 'organisations-200519'。如果我将它硬编码为字符串,我会得到相同的结果。
  • 感谢您的努力 Shachaf.Gortler!

标签: elasticsearch elasticsearch-php


【解决方案1】:

好的,所以问题不在于 ElasticSearch,事实证明来自配置的索引字符串没有被正确处理,产生一个空字符串,导致 Elastic 查询所有索引。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-07-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-09
    • 2013-11-19
    • 2019-07-28
    • 2015-07-08
    相关资源
    最近更新 更多