【发布时间】:2020-04-23 19:36:59
【问题描述】:
我正在尝试基于名为 _id 的字段在 Elastic 搜索中运行正则表达式查询,但出现此错误:
只能在关键字和文本字段上使用通配符查询 - 不能在 [_id] 类型为 [_id]
我试过regexp:
{
"query": {
"regexp": {
"_id": {
"value": "test-product-all-user_.*",
"flags" : "ALL",
"max_determinized_states": 10000,
"rewrite": "constant_score"
}
}
}
}
和wildcard:
{
"query": {
"wildcard": {
"_id": {
"value": "test-product-all-user_.*",
"boost": 1.0,
"rewrite": "constant_score"
}
}
}
}
但是两者都抛出了同样的错误。
这是完整的错误以防万一:
{ "error": { "root_cause": [ { "type": "query_shard_exception", "reason": "Can only use wildcard queries on keyword and text fields - not on [_id] which is of type [_id]", "index_uuid": "Cg0zrr6dRZeHJ8Jmvh5HMg", "index": "explore_segments_v3" } ], "type": "search_phase_execution_exception", "reason": "all shards failed", "phase": "query", "grouped": true, "failed_shards": [ { "shard": 0, "index": "explore_segments_v3", "node": "-ecTRBmnS2OgjHrrq6GCOw", "reason": { "type": "query_shard_exception", "reason": "Can only use wildcard queries on keyword and text fields - not on [_id] which is of type [_id]", "index_uuid": "Cg0zrr6dRZeHJ8Jmvh5HMg", "index": "explore_segments_v3" } } ] }, "status": 400 }
【问题讨论】:
标签: regex elasticsearch