eagle
eagle

Reputation: 312

elasticdump import index setting not working

I am able to export index setting using below command

elasticdump --input=http://localhost:9200/tempIndex --output=/Users/Desktop/indexFile --type=settings

but when i tried to import the same setting it is not updating the index setting

The command i used for import is :

elasticdump --input=/Users/Desktop/indexFile --output=http://localhost:9200/tempIndex --type=settings

output of command :

 07:06:33 GMT | starting dump
 07:06:33 GMT | got 1 objects from source file (offset: 0)
 07:06:34 GMT | sent 1 objects to destination elasticsearch, wrote 0
 07:06:34 GMT | got 0 objects from source file (offset: 1)
 07:06:34 GMT | Total Writes: 0
 07:06:34 GMT | dump complete

Below is the settings of my index exported using elasticdump settings option

{
    "tempIndex":{
        "settings":{
            "index":{
                "mapping":{
                    "nested_fields":{
                        "limit":"2000"
                    },
                    "total_fields":{
                        "limit":"2000"
                    }
                },
                "analysis":{
                    "normalizer":{
                        "lowercase_normalizer":{
                            "filter":[
                                "lowercase"
                            ],
                            "type":"custom",
                            "char_filter":[

                            ]
                        }
                    }
                },
                "number_of_shards":"5",
                "number_of_replicas":"1"
            }
        }
    }
}

Upvotes: 3

Views: 3076

Answers (2)

eagle
eagle

Reputation: 312

Settings can only be added on index creation. So the index must not exist when running this command. You can short-circuit by supplying the appropriate URL, but it still would fail due to the fact that you are trying to update non-dynamic settings.

{
    "error": {
        "root_cause": [{
            "type": "illegal_argument_exception",
            "reason": "Can't update non dynamic settings [[index.number_of_shards]] for open indices [[source_index/_OdHe-IVQBemJ3YYka_9hg]]"
        }],
        "type": "illegal_argument_exception",
        "reason": "Can't update non dynamic settings [[ index.number_of_shards]] for open indices [[source_index/_OdHe-IVQBemJ3YYka_9hg]]"
    },
    "status": 400
}

You can do

# passing in _settings path will change operation from insert to update
elasticdump --input=/Users/Desktop/indexFile --output=http://localhost:9200/tempIndex/_settings --type=settings

reference:https://github.com/taskrabbit/elasticsearch-dump/issues/549#issuecomment-501223008

Upvotes: 1

Pierre-Nicolas Mougel
Pierre-Nicolas Mougel

Reputation: 2279

I believe that elasticdump is hiding an error from elasticsearch here. If the index tempIndex already exists, then you cannot update the number_of_shards and analysis settings. These settings are not dynamic. Try running :

POST /tempIndex/_settings
{
    "tempIndex":{
        "settings":{
            "index":{
                "mapping":{
                    "nested_fields":{
                        "limit":"2000"
                    },
                    "total_fields":{
                        "limit":"2000"
                    }
                },
                "analysis":{
                    "normalizer":{
                        "lowercase_normalizer":{
                            "filter":[
                                "lowercase"
                            ],
                            "type":"custom",
                            "char_filter":[

                            ]
                        }
                    }
                },
                "number_of_shards":"5",
                "number_of_replicas":"1"
            }
        }
    }
}

You are likely to get an error from elasticsearch. Since the request is invalid, no settings will be updated.

You can either remove the index tempIndex if that is possible or remove the settings that are not dynamic from indexFile.

Upvotes: 0

Related Questions