gpt4 book ai didi

php - Elasticsearch - 希望在该特定字段可用或不可用的所有索引中按字段排序,如果不可用,则避免它

转载 作者:行者123 更新时间:2023-12-02 22:10:52 27 4
gpt4 key购买 nike

目前,根据评分获得结果但我想要做的是我想要基于 的结果评分 + 字段状态,值为真/假。

如果值为真,则需要导致优先级,但有 状态字段不存在的可能性在所有指数中。

           "query" => [
'bool' => [
'filter' => $filter,
'must' => [
"multi_match" => [
'query' => "$string",
"type" => "cross_fields",
'fields' => ['field1','field2','field3'],
"minimum_should_match" => "80%"
]
]
]
],
"sort" => [
"_score",
[ "status" => ["order" => "desc","unmapped_type" => "boolean"] ]
],

但得到以下错误:
[type] => illegal_argument_exception
[reason] => Text fields are not optimised for operations that require per-document field data like aggregations and sorting, so these operations are disabled by default. Please use a keyword field instead. Alternatively, set fielddata=true on [status] in order to load field data by uninverting the inverted index. Note that this can use significant memory.

任何人都可以帮助我忽略该字段不可用的索引或任何其他解决此问题的方法?

最佳答案

正如聊天中所讨论的,问题是由@jilesh 引起的

忘记删除旧的索引映射,只更新这件事发生的数据。

当您通过正确设置出现以下错误时,以下答案是相关的

Text fields are not optimised for operations that require per-document field data like aggregations and sorting, so these operations are disabled by default. Please use a keyword field instead. Alternatively, set fielddata=true on [status] in order to load field data by uninverting the inverted index. Note that this can use significant memory.



在这种情况下,如果您想消除错误,请启用字段上的字段数据,但要注意它可能会导致性能问题。

阅读有关 field data on official site 的更多信息.

您可以在您的 order 中启用它映射中的字段,如图所示。
{
"properties": {
"order": {
"type": "text",
"fielddata": true
}
}
}

关于php - Elasticsearch - 希望在该特定字段可用或不可用的所有索引中按字段排序,如果不可用,则避免它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62043037/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com