【发布时间】:2020-04-29 15:09:17
【问题描述】:
我喜欢在对象内部的字符串字段上运行嵌套术语聚合。
通常,我使用这个查询
"terms": {
"field": "fieldname.keyword"
}
启用字段数据
但对于这样的嵌套文档,我无法做到这一点
{
"nested": {
"path": "objectField"
},
"aggs": {
"allmyaggs": {
"terms": {
"field": "objectField.fieldName.keyword"
}
}
}
}
上面的查询只是返回一个空的桶数组
有没有办法在索引映射期间默认不启用字段数据。 因为这将占用大量堆内存,而我已经加载了大量数据而没有它
文档映射
{
"mappings": {
"properties": {
"productname": {
"type": "nested",
"properties": {
"productlineseqno": {
"type": "text"
},
"invoiceitemname": {
"type": "text"
},
"productlinename": {
"type": "text"
},
"productlinedescription": {
"type": "text"
},
"isprescribable": {
"type": "boolean"
},
"iscontrolleddrug": {
"type": "boolean"
}
}
}
示例文档
{
"productname": [
{
"productlineseqno": "1.58",
"iscontrolleddrug": "false",
"productlinename": "Consultations",
"productlinedescription": "Consultations",
"isprescribable": "false",
"invoiceitemname": "invoice name"
}
]
}
固定
通过更改映射来启用字段数据
【问题讨论】:
标签: elasticsearch elastic-stack