gpt4 book ai didi

java - Elasticsearch 查询不返回任何内容

转载 作者:行者123 更新时间:2023-12-01 10:03:35 25 4
gpt4 key购买 nike

我索引了以下文档,但是当我运行搜索时它没有返回任何内容,我想知道这是否是查询的问题。我正在尝试搜索其中包含“狗”一词的任何嵌套消息。这是文档:

{
"_index": "thread_and_messages",
"_type": "thread",
"_id": "3",
"_score": 1.0,
"_source": {
"thread_id": 3,
"thread_name": "I play the guitar",
"created": "Wed Apr 13 2016",
"thread_view": 2,
"first_nick": "Test User",
"messages": [{
"message_text": " I like dogs",
"message_id": 13,
"message_nick": "Test"
}],
"site_name": "Test Site"
}
}

这是我运行curl命令时运行的查询:

{
"function_score": {
"functions": [{
"field_value_factor": {
"field": "thread_view",
"modifier": "log1p",
"factor": 2
}
}],
{"query": {
"bool": {
"should": [{
"match": {
"thread_name": "dogs"
}
}, {
"nested": {
"path": "messages",
"query": {
"bool": {
"should": [{
"match": {
"messages.message_text": "dogs"
}
}]
}
},
"inner_hits": {}
}
}]
}
}
}
}

最佳答案

您拥有的映射加上经过稍微修改的查询的示例文档对我来说很有效:

curl -XGET "http://localhost:9200/thread_and_messages/thread/_search" -d'
{
"query": {
"function_score": {
"functions": [
{
"field_value_factor": {
"field": "thread_view",
"modifier": "log1p",
"factor": 2
}
}
],
"query": {
"bool": {
"should": [
{
"match": {
"thread_name": "dogs"
}
},
{
"nested": {
"path": "messages",
"query": {
"bool": {
"should": [
{
"match": {
"messages.message_text": "dogs"
}
}
]
}
},
"inner_hits": {}
}
}
]
}
}
}
}
}'

关于java - Elasticsearch 查询不返回任何内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36626547/

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