您需要在索引中具有术语的未标记化副本,在映射中使用多字段:
{ "test": { "mappings": { "book": { "properties": { "author": { "type": "string", "fields": { "untouched": { "type": "string", "index": "not_analyzed" } } }, "title": { "type": "string", "fields": { "untouched": { "type": "string", "index": "not_analyzed" } } }, "docType": { "type": "string", "fields": { "untouched": { "type": "string", "index": "not_analyzed" } } } } } } }}在聚合查询中,引用未标记的字段:
"aggs" : { "author" : { "terms" : { "field" : "author.untouched", "size": 20, "order" : { "_term" : "asc" } } }, "title" : { "terms" : {"field" : "title.untouched","size": 20 } }, "contentType" : { "terms" : { "field" : "docType.untouched", "size": 20 } }}


