Elasticsearch - add a constant mapping definition to a specific type in the mapping


(Mysurf Mail) #1

I have the following mapping (static mapping)

{
	"settings": {},
	"mappings": {
		"MyEntity": {
			"properties": {
				"date": {
					"type": "date",
					"format": "dateOptionalTime"
				},
				"name": {
					"type": "string",
				},
				"tweet": {
					"type": "string"
				},
				"user_id": {
					"type": "long"
				}
			}
		}
	}
}

where "MyEntity" is an example of one of many entities.
What I want is that every time an entity has the value:

"name": { 
      "type": "string",
 },

It will add the following

"name": {
	"type": "string",
	"analyzer": "mm_name_analyzer",
	"fields": {
		"lc": {
			"type": "string",
			"analyzer": "case_insensitive_sort"
		},
		"raw": {
			"type": "string",
			"index": "not_analyzed"
		}
	}
}

Is there a way to do it?


(Mark Walkom) #2

That's a multifield which should work fine, have you tried it?


(Mysurf Mail) #3

@warkolm: Thanks.I am trying to add multi fields to an entity.
Thing is - my template is static.

Lets say I have many types of entities as in "My_Entity" (as in the example in the link).
And I want to add to all the properties of type string this settings -
If my mapping is not dynamic - I can't set is with the dynamic template feature.


(Mark Walkom) #4

Then you're stuck, you either need to move to dynamic or stick with what you have. There is no way to do a bit of each.


(system) #5