1

Take the simplest case of indexing the following document in elasticsearch

{ "name": "Mark", "age": 28 } 

With automatic mapping the mapping for this index would now look like

"properties" : { "doc" : { "properties" : { "age" : { "type" : "long"}, "name" : { "type" : "string" } } }, 

But say I then wanted to allow the case where this document should be indexed

{ "name": "Bill", "age": "seven" } 

If I try this the mapping does not update and elasticsearch throws an error since there is a conflict with the type of the age property. Is there any way to do this so both docs could be automatically indexed and consequently queryable?

1

3 Answers 3

2

Mappings are defined per type so what you could do is having two types in your index:

  1. numeric
  2. alphabetical

And split the documents according to the value in the age field. If you run a query you can query both types.

Sign up to request clarification or add additional context in comments.

2 Comments

@MeiSign- How do i go about telling elasticsearch to Consider everything but dates as strings?
I never did that actually but I guess if you create the Index you could set the numeric detection to false for example:|elasticsearch.org/guide/en/elasticsearch/reference/current/…
1

you can add new fields and update a mapping. But you cannot update a mapping.To do that you need to drop the index and create a new mapping and index the data..!

For more info refer this link reference

Comments

1

You can't change existing mapping.You can only add new field in it. Or you have to delete old mapping & create a new mapping for that particular index.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.