gpt4 book ai didi

ElasticSearch仅查询嵌套是否存在

转载 作者:行者123 更新时间:2023-12-03 03:43:55 27 4
gpt4 key购买 nike

我有这个搜索查询来查找根标题和描述中的查询搜索词“reddog”,并且还匹配嵌套的评论文档。

GET /_all/video/_search
{
"query":{
"bool":{
"should":[
{
"multi_match":{
"query":"red dog",
"fields":[
"Title",
"Description"
],
"type": "cross_fields",
"operator":"and"
}
},
{
"nested":{
"path":"Comments",
"query":{
"multi_match":{
"query":"red dog",
"fields":[
"Comments.Description",
"Comments.Description.folded"
],
"type": "cross_fields",
"operator":"and"
}
}
}
}
]
}
}
}

不幸的是,当我将注释持久化到 ElasticSearch 时,注释有时为空,是否可以执行某种“如果文档存在则包含”条件?

更新

我仍然遇到同样的错误

[nested] failed to find nested object under path [Comments]

当我尝试使用存在进行查询时

    GET /_all/video/_search
{
"query":{
"bool":{
"should":[
{
"multi_match":{
"query":"lisa",
"fields":[
"Title",
"Description"
],
"type":"cross_fields",
"operator":"and"
}
},
{
"nested":{
"path":"Comments",
"query":{
"filtered":{
"query":{
"match_all":{}
},
"filter":{
"exists":{
"field":"Comments.Description"
}
}
}
}
}
}
]
}
}
}

我的一切映射

{
"en":{
"mappings":{
"video":{
"properties":{
"Comments":{
"type":"nested",
"properties":{
"Description":{
"type":"string",
"analyzer":"english",
"fields":{
"folded":{
"type":"string",
"analyzer":"folding"
}
}
}
}
},
"Description":{
"type":"string",
"analyzer":"english",
"fields":{
"folded":{
"type":"string",
"analyzer":"folding"
}
}
},
"Title":{
"type":"string",
"analyzer":"english",
"fields":{
"folded":{
"type":"string",
"analyzer":"folding"
}
}
}
}
}
}
}
}

以及我的设置

{
"settings": {
"analysis": {
"analyzer": {
"folding": {
"tokenizer": "standard",
"filter": [
"lowercase",
"asciifolding"
]
}
}
}
}
}

最佳答案

事实证明,我有一个 Marvel 索引,它没有我输入的映射。我删除了该插件,在所有索引中搜索都很好。

关于ElasticSearch仅查询嵌套是否存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28902339/

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