命名QUERY ELASTICSEARCH无法在A内部工作
我试图使用名为查询以查看已满符号的条件,无论是tag-one还是tag-two,但它不起作用,实现此目的的正确方法是什么? 示例指出,“ _name”标签应在bool中使用,因此我不确定问题可能是什么。
GET /myindex/_search
{
"_source": ["ids"],
"query": {
"bool": {
"must": [
{
"range": {
"timestamp": {
"format": "strict_date_optional_time",
"gte": "2022-02-21T20:44:07.099Z",
"lte": "2022-03-23T20:44:07.099Z"
}
}
},
{
"bool": {
"should": [
{
"_name": "tag-one",
"query_string": {
"query":"*hello*",
"fields":["field1","field2","field3"]
}
},
{
"query_string": {
"query":"*world*",
"fields":["field1","field2","field3"]
},
"_name": "tag-two"
}
]
}
}
]
}
},
"size": 10000
}
我得到的错误:
{
"error" : {
"root_cause" : [
{
"type" : "parsing_exception",
"reason" : "[_name] query malformed, no start_object after query name",
"line" : 19,
"col" : 18
}
],
"type" : "x_content_parse_exception",
"reason" : "[19:18] [bool] failed to parse field [must]",
"caused_by" : {
"type" : "x_content_parse_exception",
"reason" : "[19:18] [bool] failed to parse field [should]",
"caused_by" : {
"type" : "parsing_exception",
"reason" : "[_name] query malformed, no start_object after query name",
"line" : 19,
"col" : 18
}
}
},
"status" : 400
}
Im trying to use Named Queries to see which condition was met, either tag-one or tag-two, but its not working, what is the correct way to achieve this?
The example states that the "_name" tag should be used inside a bool which is it, so im not sure what the problem could be.
GET /myindex/_search
{
"_source": ["ids"],
"query": {
"bool": {
"must": [
{
"range": {
"timestamp": {
"format": "strict_date_optional_time",
"gte": "2022-02-21T20:44:07.099Z",
"lte": "2022-03-23T20:44:07.099Z"
}
}
},
{
"bool": {
"should": [
{
"_name": "tag-one",
"query_string": {
"query":"*hello*",
"fields":["field1","field2","field3"]
}
},
{
"query_string": {
"query":"*world*",
"fields":["field1","field2","field3"]
},
"_name": "tag-two"
}
]
}
}
]
}
},
"size": 10000
}
the error I get:
{
"error" : {
"root_cause" : [
{
"type" : "parsing_exception",
"reason" : "[_name] query malformed, no start_object after query name",
"line" : 19,
"col" : 18
}
],
"type" : "x_content_parse_exception",
"reason" : "[19:18] [bool] failed to parse field [must]",
"caused_by" : {
"type" : "x_content_parse_exception",
"reason" : "[19:18] [bool] failed to parse field [should]",
"caused_by" : {
"type" : "parsing_exception",
"reason" : "[_name] query malformed, no start_object after query name",
"line" : 19,
"col" : 18
}
}
},
"status" : 400
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
来自
您需要在
query_string
中包括_ Named
查询。将您的搜索查询修改为From Elasticsearch documentation
You need to include the
_named
query inside thequery_string
. Modify your search query as