Hello! Here's my issue:
1. I create an index with a mapping that has a dynamic template. 2. I create a new document that contains a new field that will match a dynamic template in the mapping and that will be added to the mapping. The PUT succeeds with 201 Created. 3. I then retrieve the mapping with a GET to check that the new field has been correctly added. The GET succeeds with 200 OK. 4. The returned mapping doesn't always contain the newly created field. It sometimes takes a small delay (< 1s) for the updated mapping to be returned. Seems like a race condition, so I'm wondering if this is expected behaviour and if there is a setting or parameter that can be set to guarantee that the mapping gets refreshed atomically, just like you can force-refresh an index. This is not currently a show-stopping issue, I'd just like to have a definitive answer. The reason I need the mapping to reflect the changes immediately is that I have unit tests that depend on field information retrieved from the mapping at run-time and they sporadically fail because the returned mapping and the expected mapping don't always match up. Here's a curl recreation script: https://gist.github.com/elasticsearcher/7f116867603a44575ce1 However, it seems that curl is slow enough that the small delay needed for the mapping to refresh passes in-between curl calls and the script doesn't actually reproduce the issue. I hence created an equivalent Python script that retries the whole process until the issue is demonstrated: https://gist.github.com/elasticsearcher/2dff7ee44e11c6a39bfb Here's a sample output from the script (contains a few iterations of the entire recreation cycle): > /bin/python es_mapping_race_condition.py Delete index /documents: {"acknowledged":true} Create index /documents: {"acknowledged":true} Create mapping /documents/pdf: {"acknowledged":true} Create new /documents/pdf document: {"_index":"documents","_type":"pdf","_id":"AUvcWwZgoOHS3xjDkoFH","_version":1,"created":true} Refresh index /documents {"_shards":{"total":10,"successful":5,"failed":0}} Retrieved fields: [u'new_field_str', u'new_field_str.tags_str', u'title_str', u'title_str.tags_str'] Delete index /documents: {"acknowledged":true} Create index /documents: {"acknowledged":true} Create mapping /documents/pdf: {"acknowledged":true} Create new /documents/pdf document: {"_index":"documents","_type":"pdf","_id":"AUvcWwsCoOHS3xjDkoFI","_version":1,"created":true} Refresh index /documents {"_shards":{"total":10,"successful":5,"failed":0}} Retrieved fields: [u'new_field_str', u'new_field_str.tags_str', u'title_str', u'title_str.tags_str'] Delete index /documents: {"acknowledged":true} Create index /documents: {"acknowledged":true} Create mapping /documents/pdf: {"acknowledged":true} Create new /documents/pdf document: {"_index":"documents","_type":"pdf","_id":"AUvcWxDioOHS3xjDkoFJ","_version":1,"created":true} Refresh index /documents {"_shards":{"total":10,"successful":5,"failed":0}} Retrieved fields: [u'title_str', u'title_str.tags_str'] ######################################################################## # # Field 'new_field_str' was not found in the mapping. # ######################################################################## Thanks in advance for any help! -- You received this message because you are subscribed to the Google Groups "elasticsearch" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/88e7df12-e862-442b-8e15-3c2a6fcae7d4%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
