gpt4 book ai didi

Elasticsearch 更多类似产品 没有结果

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

我正在尝试弄清楚 More like this 查询是如何工作的 (ES 2.X)。我用术语向量创建了以下索引。

PUT /test_index
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0
},
"mappings": {
"doc": {
"properties": {
"text": {
"type": "string",
"term_vector": "yes"
}
}
}
}
}

PUT /test_index/doc/1
{
"text": ["Hello","World"]
}

PUT /test_index/doc/2
{
"text": ["This","is","me"]
}

PUT /test_index/doc/3
{
"text": ["Hello","World"]
}

PUT /test_index/doc/4
{
"text": ["Hello","World","World"]
}

为什么下面的查询没有返回结果?对于第二个查询,我希望至少检索 doc 3,它与 doc 1 具有相同的值。

POST /test_index/doc/_search
{
"query": {
"more_like_this": {
"like": "Hello",
"min_term_freq": 1
}
}
}

POST /test_index/doc/_search
{
"query": {
"more_like_this": {
"fields": [
"text"
],
"like": [
{
"_index": "test_index",
"_type": "doc",
"_id": "1"
}
]
}
}
}

最佳答案

默认 min_doc_freq 为 5,因此您的查询不起作用,因为您的索引不包含至少 5 个 term 属性为黄色的文档。因此,在您的查询中将 min_doc_freq 设置为 1,它应该可以工作。

{
"query": {
"more_like_this": {
"like": "Hello",
"min_term_freq": 1,
"min_doc_freq": 1
}
}
}

关于Elasticsearch 更多类似产品 没有结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40236844/

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