python - Creating analyzed and not_analyzed index on all fields in Elasticsearch -
im pretty new elasticsearch. have requirement of creating string fields "analyzed" , "not_analyzed" index. have been able 1 or 2 fields, how can if have 50 fields in document? have used following code create such index on few fields:
mapping = { "my_type": { "properties": { "random_num": {"type": "string"}, "category": { "type":"multi_field", "fields":{ "category":{ "type":"string", "index":"analyzed" },"untouched":{ "type":"string", "index":"not_analyzed" } } }, "url": {"type": "string"}, "id": {"type": "string"}, "desc": { "type":"multi_field", "fields":{ "desc":{ "type":"string", "index":"analyzed" },"untouched":{ "type":"string", "index":"not_analyzed" } } } } } }
i appreciate if 1 me out this. thanks!
you can go through document here. using dynamic index templates , can add rules below , achienve same. in following example , have enabled additional field called raw if size less 256 not_analyzed.
{ "mappings": { "my_type": { "dynamic_templates": [ { "string_fields": { "mapping": { "type": "string", "fields": { "raw": { "index": "not_analyzed", "ignore_above": 256, "type": "string" } } }, "match_mapping_type": "string", "match": "*" } } ] } } }
Comments
Post a Comment