GET my_test_index/_search { "query": { "bool": { "must": [ { "term": { "Type": "2" //子文档条件 } }, { "has_parent": { "parent_type": "parent_table", //父文档 "query": { "match": { "number": "5203021066009201800035" //父文档条件 } } } } ] } }, "aggs":{ "type_count":{ "cardinality":{ "field":"Type" } } } }
执行上述聚合查询报一下错误
“type”: “illegal_argument_exception”,
“reason”: “Fielddata is disabled on text fields by default. Set fielddata=true on [Type] 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.”