gpt4 book ai didi

elasticsearch - Elasticsearch 查询因query_string中的冒号而崩溃

转载 作者:行者123 更新时间:2023-12-03 00:18:13 32 4
gpt4 key购买 nike

我在查询字词"query": "Schwarz AND People:"的末尾添加了一个冒号,这似乎破坏了查询。不知道为什么。这是 flex 搜索中的错误吗?我正在使用1.0.1。响应包含此令人困惑的异常。

: Encountered "<EOF>" at line 1, column 19. Was expecting one of: <BAREOPER> ... "(" ... "" ... <QUOTED> ... <TERM> ... <PREFIXTERM> ... <WILDTERM> ... <REGEXPTERM> ... "[" ... "{" ... <NUMBER> ... ]; nested: ParseException[Encountered "<EOF>" at line 1, column 19. Was expecting one of: <BAREOPER> ... "(" ... "" ... <QUOTED> ... <TERM> ... <PREFIXTERM> ... <WILDTERM> ... <REGEXPTERM> ... "[" ... "{" ... <NUMBER> ... ]; }{[R7VEhVnkSnS2FW980lP6BA][facebook_posts][26]:*



下面是由于冒号而中断的查询。我需要冒号怎么办?
{
"query": {
"filtered": {
"query": {
"bool": {
"must": [
{
"query_string": {
"fields": [
"name",
"message"
],
"query": "Schwarz AND People:"
}
},
{
"range": {
"created_time": {
"gte": 1363219771,
"lte": 1449623371
}
}
}
]
}
}
}
},
"size": 20,
"sort": [
{
"total_interactions": {
"order": "desc"
}
}
],
"highlight": {
"fields": {
"name": {
"pre_tags": [
"<strong>"
],
"post_tags": [
"</strong>"
],
"fragment_size": 500,
"number_of_fragments": 1
},
"message": {
"pre_tags": [
"<strong>"
],
"post_tags": [
"</strong>"
],
"fragment_size": 500,
"number_of_fragments": 1
}
}
}
}

最佳答案

query_string中的冒号还用作字段和查询词之间的定界符,如here所示。

结果,它将其解析为无效查询。为了将冒号指定为查询词,您需要显式转义它。

范例:

{
"query": {
"filtered": {
"query": {
"bool": {
"must": [
{
"query_string": {
"fields": [
"name",
"message"
],
"query": "Schwarz AND People\\:"
}
},
{
"range": {
"created_time": {
"gte": 1363219771,
"lte": 1449623371
}
}
}
]
}
}
}
},
"size": 20,
"sort": [
{
"total_interactions": {
"order": "desc"
}
}
],
"highlight": {
"fields": {
"name": {
"pre_tags": [
"<strong>"
],
"post_tags": [
"</strong>"
],
"fragment_size": 500,
"number_of_fragments": 1
},
"message": {
"pre_tags": [
"<strong>"
],
"post_tags": [
"</strong>"
],
"fragment_size": 500,
"number_of_fragments": 1
}
}
}
}

关于elasticsearch - Elasticsearch 查询因query_string中的冒号而崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34169158/

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