Templates added but reindexing existing data doesn't use them

I've finally gotten geo_distance queries to function. Apparently,
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?

--

Quick answers inline.

On Wed, Nov 14, 2012 at 9:40 AM, InquiringMind brian.from.fl@gmail.comwrote:

  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

--

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.

--