W
W
Woice2017-11-23 17:39:12
PHP
Woice, 2017-11-23 17:39:12

How to update field type in elasticsearch mapping?

PHP version - 7.
Elastic version - 2.3.3
The machine already had several indexes. I had a task to create a new one using a special script and upload it to elastic.
The mapping file was segenerated - this file is "typical" for us. In other indices, it is the same, in theory.
An archive file was generated - in which there is an entry, like:
5a16dc251912a325111231.jpeg
It seems that everything went fine and my "archive" was added without errors. However, when searching, the elastic swears a lot, the logs show this:
5a16dc8068188705393952.png
("merging/reducing the aggregations failed when computing the aggregation [Name: Archive, Type: terms] because: the field you gave in the aggregation query existed as two different types in two different indices"
)
5a16dd180abb4113001141.png5a16dcf586e7b862489909.png
I tried to delete the line where I have a long and add again, the situation has not changed.
Tried to run this script:
curl -XPUT 'localhost:9200/rguu/_mapping/archive?pretty' -H 'Content-Type: application/json' -d'{ "properties": { "sort": { "type": "integer" } }}'
After execution, it says "everything is fine", but nothing changes in the mapping.
How to change it at all? How to create it?
Am I doing everything right and understanding?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
W
Woice, 2017-11-24
@Woice

In general, the issue was decided a little differently (the simplest and most effective so far).
Since all my indexes are created according to typical mappings, which, for some reason, did not have only 1 index, I managed to solve the problem through _template.
1. Before creating the index, I created a template with the template template: "rguu*" and my own "typical" mapping.
2. Further created an index rguu_10 (already the 10th attempt).
3. For the test, I filled in several problematic index types.
Only such a situation was able to create an adequate index and the mapping "picked up".

A
Alexey Cheremisin, 2017-11-23
@leahch

Disappointing - the mapping can not be updated! You can only add new fields.
Your actions - make a new index with the correct mapping before uploading data to this index , pour the old data there, for example, via _reindexapi - https://www.elastic.co/guide/en/elasticsearch/refe...
And yes, aggregations with different types of the same field will not work.
How to create a mapping? A separate song - described in detail here - https://www.elastic.co/guide/en/elasticsearch/ref...
Usually done before uploading data. There, besides mapping, there are settings - a separate song.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question