6

I have an index with mapping. I decided to add a new field to existing mapping:

{

  "properties": {
    "sexifield": {
      "type": "keyword",
      "null_value": "NULL"
    }
  }

}

As far as I understand, the field should appear in existing documents when I reindex. So when I use api to reindex:

{
  "source": {
    "index": "index_v1"
  },
  "dest": {
    "index": "index_v2",
    "version_type": "external"
  }
}

I see that the mapping for index_v2 does not consist sexifield, and documents are not consisting it neither. Also this operation took less than 60ms.

Please point me, what I do not understand from it...

Adding the new documents to the first index (via java API, for an entity which has not this field (sexifield), so probably elastic should add me the default one) with sexifield, also does not create me this additional field.

Thanks in advance for tips.

Regards

1 Answer 1

3

great question +1 ( I learned something while solving your problem)

I don't know the answer to how to consider the second mapping (reindexed mapping) while reindexing, but here is how I would update the reindexed index (all the documents) once the reindexing is done from original index. I still continue to research to see if there is a way to consider the default values that are defined in the mapping of the second index while reindexing, but for now see if this solution helps..

POST /index_v2/_update_by_query
{
  "script": {
    "lang": "painless",
    "inline": "ctx._source.sexifield = params.null_value",
    "params": {
      "null_value": "NULL"
    }
  }
}
Sign up to request clarification or add additional context in comments.

1 Comment

that's quite okey, but I would like to find more elastic solution, which can be more generic.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.