Change settings and mappings on existing index in Elasticsearch

前端 未结 1 902
Happy的楠姐
Happy的楠姐 2020-12-14 19:10

I would like the following settings and mapping set on an already existing index in Elasticsearch:

{
    \"analysis\": {
        \"analyzer\": {
                     


        
1条回答
  •  萌比男神i
    2020-12-14 19:23

    If you look at your settings after sending the changes you'll notice that the analyzer is not there. In fact you can't change the analysis section of the settings on a live index. Better to create it with the desired settings, otherwise you can just close it:

    curl -XPOST localhost:9200/index_name/_close
    

    While the index is closed you can send the new settings. After that you can reopen the index:

    curl -XPOST localhost:9200/index_name/_open
    

    While the index is closed it doesn't use any cluster resource, but it is not readable nor writable. If you want to close and reopen the index using the Java API you can use the following code:

    client.admin().indices().prepareClose(indexName).execute().actionGet();
    //TODO update settings
    client.admin().indices().prepareOpen(indexName).execute().actionGet();
    

    0 讨论(0)
提交回复
热议问题