elasticSearch Alternatively use a keyword field instead.
作者:互联网
es 查询的时候报错了 { "error": { "root_cause": [ { "type": "illegal_argument_exception", "reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [parent_row_id] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead." } ], "type": "search_phase_execution_exception", "reason": "all shards failed", "phase": "query", "grouped": true, "failed_shards": [ { "shard": 0, "index": "dc_org_newpearl_function_tree", "node": "1C7XnVeiRF-vCZAR2jdpnQ", "reason": { "type": "illegal_argument_exception", "reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [parent_row_id] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead." } } ], "caused_by": { "type": "illegal_argument_exception", "reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [parent_row_id] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead.", "caused_by": { "type": "illegal_argument_exception", "reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [parent_row_id] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead." } } }, "status": 400 } 参考 https://www.cnblogs.com/Neeo/articles/10771885.html 其实也就是说明 字段的类型不是keyword 类型,因此不支持 某些查询方式:比如排序,聚合 等 而且 字段条件查询 也是 查询不到内容或者想要的结果的 比如 这个字段 : "parent_row_id" : { "type" : "text", "fields" : { "keyword" : { "type" : "keyword", "ignore_above" : 256 } } }, 那么要查询 就需要额外带上 keyword 才可以 GET /dc_org_newpearl_function_tree/_search { "query": { "term": { "parent_row_id.keyword": { "value": "", "boost": 1.0 } } } } 或者 GET /dc_org_newpearl_function_tree/_search { "sort": [ { "parent_row_id.keyword": { "order": "asc" } } ] } 或者聚合查询 带上 keyword "aggregations": { "group_parent_row_id": { "terms": { "field": "parent_row_ids.keyword", "size": 100, "min_doc_count": 1, "shard_min_doc_count": 0, "show_term_doc_count_error": false, "order": [{ "_count": "desc" }, { "_key": "asc" }] } } } 或者解决办法就是 删除索引重建了,将 对应字段 类型改为keyword .startObject("parent_row_ids").field("type", "keyword").endObject()
es 查询的时候报错了
{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [parent_row_id] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead."
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "dc_org_newpearl_function_tree",
"node": "1C7XnVeiRF-vCZAR2jdpnQ",
"reason": {
"type": "illegal_argument_exception",
"reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [parent_row_id] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead."
}
}
],
"caused_by": {
"type": "illegal_argument_exception",
"reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [parent_row_id] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead.",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [parent_row_id] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead."
}
}
},
"status": 400
}
参考 https://www.cnblogs.com/Neeo/articles/10771885.html
其实也就是说明 字段的类型不是keyword 类型,因此不支持 某些查询方式:比如排序,聚合 等
而且 字段条件查询 也是 查询不到内容或者想要的结果的
比如 这个字段 :
"parent_row_id" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
那么要查询 就需要额外带上 keyword 才可以
GET /dc_org_newpearl_function_tree/_search
{
"query": {
"term": {
"parent_row_id.keyword": {
"value": "",
"boost": 1.0
}
}
}
}
或者
GET /dc_org_newpearl_function_tree/_search
{
"sort": [
{
"parent_row_id.keyword": {
"order": "asc"
}
}
]
}
或者聚合查询 带上 keyword
"aggregations": {
"group_parent_row_id": {
"terms": {
"field": "parent_row_ids.keyword",
"size": 100,
"min_doc_count": 1,
"shard_min_doc_count": 0,
"show_term_doc_count_error": false,
"order": [{
"_count": "desc"
}, {
"_key": "asc"
}]
}
}
}
或者解决办法就是 删除索引重建了,将 对应字段 类型改为keyword
.startObject("parent_row_ids").field("type", "keyword").endObject()
标签:use,fielddata,parent,Alternatively,keyword,memory,row 来源: https://www.cnblogs.com/roak/p/14359718.html