我有一个列,其中所有的值都以“ARK”开头。
number
ARK101223
ARK123422
ARK234002
ARK234177
我需要使用ElasticSearch获取与ARK匹配的列编号的所有记录。只要我将编号作为列并与ARK匹配,我就只需检索这些记录。某些记录将不将编号作为列,因此我希望忽略这些记录。
下面是我尝试但无效的查询
{
"query": {
"bool": {
"must": [
{
"prefix": {
"number.keyword": "ARK"
}
},
{
"range": {
"date_1": {
"gte": "2022-01-01 01:00:00",
"lte": "2022-03-10 01:00:00"
}
},
"sort": [
{
"date_1": {
"order": "asc"
},
"date_2": {
"order": "asc"
},
"ts": {
"order": "asc"
}
}
]
}
]
}
}
}
以下是错误:
{
"error": {
"root_cause": [
{
"type": "parsing_exception",
"reason": "[range] malformed query, expected [END_OBJECT] but found [FIELD_NAME]",
"line": 1,
"col": 155
}
],
"type": "x_content_parse_exception",
"reason": "[1:155] [bool] failed to parse field [must]",
"caused_by": {
"type": "parsing_exception",
"reason": "[range] malformed query, expected [END_OBJECT] but found [FIELD_NAME]",
"line": 1,
"col": 155
}
},
"status": 400
}
1条答案
按热度按时间vybvopom1#
如果Elasticsearch为您的索引生成了Map,那么您将有
.keyword
字段作为您的number
文本字段,并且在此基础上您可以使prefix query得到预期的结果。更新: