gpt4 book ai didi

elasticsearch - Boost elastic [更多类似内容] 数组开头的搜索查询

转载 作者:行者123 更新时间:2023-11-29 02:48:44 26 4
gpt4 key购买 nike

我有这样结构的 Elasticsearch 文档:

{
"name": "item1",
"storages": [
{"items": ["a", "b", "c", "d", "e", "f"]},
{"items": ["a 1", "b 2", "c 3", "d 4", "e 5", "f 6"]}]
}

{
"name": "item2",
"storages": [
{"items": ["d", "e", "f", "g", "h", "i", "j"]},
{"items": ["d 4", "e 5", "f 6", "g 7", "h 8", "i 9", "j 10"]}
]
}

我想搜索字符串序列,例如 ["d 4","e 5"]。为此,我使用 MoreLikeThis 查询:

{
"query": {
"more_like_this" : {
"fields" : ["storages.items"],
"like" : ["d 4","e 5"],
"min_term_freq": 1,
"min_doc_freq": 1
}
}
}

它几乎可以正常工作,但它返回“_score”:第一个文档的 0.1620518 和“_score”:第二个文档的 0.13890153。

我想提高数组开头('items')的词的分数,所以因为“d 4”、“e 5”出现在数组的开头,所以它应该排名更高。

有没有办法在 elasticsearch 中创建这样的查询?也许它不应该更像这个查询?

棘手的部分是查询可能类似于 ["d 4","e 5", "xxx"](xxx 不在文档中,但没关系)

最佳答案

正如您在 this 中看到的那样回答相关问题,

arrays are indexed—made searchable—as multivalue fields, which are unordered

因此您在搜索时不能指望顺序。

更糟糕的是,对象数组 is not stored as you think .

Arrays of objects do not work as you would expect: you cannot query each object independently of the other objects in the array. If you need to be able to do this then you should use the nested datatype instead of the object datatype.

关于elasticsearch - Boost elastic [更多类似内容] 数组开头的搜索查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38586963/

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