1.问题描述:
es组合查询时报错
报错信息:
{
"error": {
"root_cause": [
{
"type": "query_shard_exception",
"reason": "failed to create query: field:[10400001] was indexed without position data; cannot run PhraseQuery",
"index_uuid": "tfDFEQKCTVmDlAUK1wuO3A",
"index": "zkcx_ebookcollection_1987055001"
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "zkcx_ebookcollection_1987055001",
"node": "DTKIgGfRR-elySpyq6i9PQ",
"reason": {
"type": "query_shard_exception",
"reason": "failed to create query: field:[10400001] was indexed without position data; cannot run PhraseQuery",
"index_uuid": "tfDFEQKCTVmDlAUK1wuO3A",
"index": "zkcx_ebookcollection_1987055001",
"caused_by": {
"type": "illegal_state_exception",
"reason": "field:[10400001] was indexed without position data; cannot run PhraseQuery"
}
}
}
]
},
"status": 400
}
2.分析原因:
“reason”: “failed to create query: field:[10400001] was indexed without position data; cannot run PhraseQuery”,
网上查询相关信息后找到了问题的关键:
查询时,不能解析address,组合查询,字段的类型必须是text类型,keyword会报异常
3.问题解决
(1)查询映射信息
使用Postman,向ES服务器发送GET请求:
http://192.168.0.228:12000/zkcx_datacenter_do_1987055001/_mapping/
(2)修改字段映射类型为text(这一步我没有测试,领导说他来弄)
修改映射信息,Elasticsearch 不支持修改,需要删除后重新添加
使用Postman,向ES服务器发送PUT请求:http://192.168.0.228:12000/zkcx_datacenter_do_1987055001/_mapping/
参数:[Body] → [raw] → [JSON]
原文链接:https://blog.csdn.net/xzlawin/article/details/121855761