Create or update mapping in elasticsearch

后端 未结 3 1242
故里飘歌
故里飘歌 2020-12-04 21:01

I am new to Elasticsearch and am currently working on implementing a geo_distance filter for searching. As of now my index has the following mapping (I\'ve remo

3条回答
  •  悲哀的现实
    2020-12-04 21:55

    Generally speaking, you can update your index mapping using the put mapping api (reference here) :

    curl -XPUT 'http://localhost:9200/advert_index/_mapping/advert_type' -d '
    {
        "advert_type" : {
            "properties" : {
    
              //your new mapping properties
    
            }
        }
    }
    '
    

    It's especially useful for adding new fields. However, in your case, you will try to change the location type, which will cause a conflict and prevent the new mapping from being used.

    You could use the put mapping api to add another property containing the location as a lat/lon array, but you won't be able to update the previous location field itself.

    Finally, you will have to reindex your data for your new mapping to be taken into account.

    The best solution would really be to create a new index.

    If your problem with creating another index is downtime, you should take a look at aliases to make things go smoothly.

提交回复
热议问题