gpt4 book ai didi

elasticsearch - ElasticSearch-如何从动态字段元数据查询查询?

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

ElasticSearch-如何从动态字段元数据查询查询?

元数据字段是动态的,可能有是或没有内部字段。

即使其中一些未定义“已删除”字段,如何返回查询?

谢谢收听。

{
"query": {
"nested": {
"path": "metadata",
"query": {
"bool": {
"should":[
{
"match":{
"metadata.deleted": true
}
}
]
}
}
},
"bool": {
"must": {
"term": {
"on_behalf_of": "b71457f731d8a6f"
}
}
}
}
}
{
"error": {
"root_cause": [
{
"type": "parsing_exception",
"reason": "[nested] malformed query, expected [END_OBJECT] but found [FIELD_NAME]",
"line": 1,
"col": 116
}
],
"type": "parsing_exception",
"reason": "[nested] malformed query, expected [END_OBJECT] but found [FIELD_NAME]",
"line": 1,
"col": 116
},
"status": 400
}

最佳答案

您的查询格式不正确。您在这里使用两个查询nestedbool。这两个查询都必须包装在 bool(boolean) 查询的mustshouldfilter中。假设这两个条件都是匹配所必需的,则这两个查询都应包装在must查询的filterbool子句中,如下所示:

{
"query": {
"bool": {
"must": [
{
"nested": {
"path": "metadata",
"query": {
"bool": {
"should": [
{
"match": {
"metadata.deleted": true
}
}
]
}
}
}
},
{
"must": {
"term": {
"on_behalf_of": "b71457f731d8a6f"
}
}
}
]
}
}
}

关于elasticsearch - ElasticSearch-如何从动态字段元数据查询查询?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57030494/

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