# Templates added but reindexing existing data doesn't use them

**URL:** <https://discuss.elastic.co/t/templates-added-but-reindexing-existing-data-doesnt-use-them/9718>\
**Category:** Elasticsearch\
**Created:** [November 14, 2012, 5:40pm UTC](https://discuss.elastic.co/t/templates-added-but-reindexing-existing-data-doesnt-use-them/9718 "2012-11-14T17:40:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![brian\_yoder](https://avatars.discourse-cdn.com/v4/letter/b/f1d935/32.png) [@brian\_yoder](https://discuss.elastic.co/u/brian_yoder)\
**Post date:** [November 14, 2012, 5:40pm UTC](https://discuss.elastic.co/t/templates-added-but-reindexing-existing-data-doesnt-use-them/9718/1 "2012-11-14T17:40:15Z")

</div>

I've finally gotten geo\_distance queries to function. Apparently,  
[http://www.elasticsearch.org/guide/reference/api/admin-indices-templates.htmlsays](http://www.elasticsearch.org/guide/reference/api/admin-indices-templates.htmlsays) that the config/templates subdirectory can be used to hold templates  
but that doesn't work on ES 19.10. So curl -XPUT works.

But I do have two questions:

1. Should re-indexing existing data pick up the mappings in a newly added  
template, or is that done only when the index is initially created?

I completely erased my current test data, and then reloaded it without  
storing the geo\_point mappings template. As expected, my geo\_distance  
queries failed with exceptions.

So then I -XPUT the template and the mappings are seen. And as expected,  
the geo\_distance queries against the current data still fail.

But when I re-indexed all of the data (scan + index each and every  
document), the geo\_distance queries still failed the same way.

It was only when I deleted the index and then reloaded the data that the  
geo\_distance queries worked.

1. Does changing the indexing configuration automatically reindex existing  
data?

Earlier, I was working to get the default analyzer to disable stopwords and  
add the snowball stemming. Really cool. Especially with one of Shay's posts  
that showed how to put this into my elasticsearch.yml file and have it  
enabled for all indices.

So then I tried some migration test cases. I first stopped ES and rm -rf  
the data directory. I then restarted ES, bulk-loaded my data, and confirmed  
that indeed I could not find org=and because the built-in default analyzer  
defines AND as a stopword.

Then I stopped ES and updated the elasticsearch.yml configuration with the  
overrides. But when I restarted ES and queried the existing data, I could  
now find org=and successfully. I didn't need to reindex. I even found  
org=sunny to match "Sunny's Sunglasses" (one of my stemming test cases).

It's as if ES detected the updated \_default analyzer configuration and  
re-indexed my data for me as it started up. Is this a correct assumption?

--

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [November 14, 2012, 6:03pm UTC](https://discuss.elastic.co/t/templates-added-but-reindexing-existing-data-doesnt-use-them/9718/2 "2012-11-14T18:03:16Z")

</div>

Quick answers inline.

On Wed, Nov 14, 2012 at 9:40 AM, InquiringMind [brian.from.fl@gmail.com](mailto:brian.from.fl@gmail.com)wrote:

> 1. Should re-indexing existing data pick up the mappings in a newly added  
> template, or is that done only when the index is initially created?

The template is only read when the index is created.

1. Does changing the indexing configuration automatically reindex existing

> data?

Changing any configuration will not reindex existing data.

Cheers,

Ivan

--

---

<div class="post-metadata">

**Author:** ![brian\_yoder](https://avatars.discourse-cdn.com/v4/letter/b/f1d935/32.png) [@brian\_yoder](https://discuss.elastic.co/u/brian_yoder)\
**Post date:** [November 15, 2012, 2:48am UTC](https://discuss.elastic.co/t/templates-added-but-reindexing-existing-data-doesnt-use-them/9718/3 "2012-11-15T02:48:15Z")

</div>

Thanks for the quick response!

I found out that the config/mappings/\_default subdirectory can hold mapping files that are read when an index is first created. So now I can store the geo\_point mappings in the code repo, deploy them with the other configs, and no need to use curl or other client to add them. All nodes need ES deployed, so being part of the install package makes it easy to keep them all seeing the same mappings.

It would be nice if ES would let me specify a type of \_all or \* as it does with an index. But for now, this works very well.

--

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 3:04am UTC](https://discuss.elastic.co/t/templates-added-but-reindexing-existing-data-doesnt-use-them/9718/4 "2017-07-06T03:04:11Z")

</div>


