i have many fields within index field name ends in _count (e.g. page_count
, order_count
etc.) , want these long
. tried create thought default mapping follows:
{ "mappings": { "_default_": { "_all": { "enabled": false, "norms": { "enabled": false } }, "properties": { "*_count": { "type": "long" } } } }, "settings": { "index.query.default_field": "message", "number_of_replicas": 2, "number_of_shards": 3 }, "template": "core-app-*" }
however, doesn't seem work have string fields in recent index:
"page_count":{ "type":"text", "fields":{ "keyword":{ "type":"keyword", "ignore_above":256 } } }
is right way create mapping based on wildcard? i'm assuming not because doesn't seem work... :)
you can achieve using dynamic templates
feature in elasticsearch.
put _template/core-app-template { "template": "core-app-*", "settings": { "index.query.default_field": "message", "number_of_replicas": 2, "number_of_shards": 3 }, "mappings": { "_default_": { "_all": { "enabled": false, "norms": { "enabled": false } } }, "my_type": { "dynamic_templates": [ { "_count_as_long": { "match_mapping_type": "*", "match": "*_count", "mapping": { "type": "long" } } } ] } } }
note: watch out index_type
in above example took liberty define my_type
when creating index template
use actual index_type
in place of my_type
Comments
Post a Comment