一 用命令操作
在ElasticSearch中默认fielddata默认是false的,因为开启Text的fielddata后对内存的占用很高
curl -i -H "Content-Type:application/json" -XPUT 127.0.0.1:9200/your_index/_mapping/your_type/?pretty -d'{"your_type":{"properties":{"your_field_name":{"type":"text","fielddata":true}}}}'
例如
curl -i -H "Content-Type:application/json" -XPUT 127.0.0.1:9200/contacts/_mapping/_doc/?pretty -d'{"_doc":{"properties":{"creater":{"type":"text","fielddata":true}}}}'
index:contacts
type: _doc
field_name:creater
二 es 插件操作
复合查询
contacts/_doc/_search GET
contacts/_mapping/_doc/?pretty POST
{"_doc":{"properties":{"creater":{"type":"text","fielddata":true}}}}