<p dir="auto">An optional parameter on the facet, like sort's "ignore_unmapped" parameter would be great.</p>
<p dir="auto">Context : We use "dynamic_templates" in our index mapping and allow clients to search, sort, and "facet" on any field that is valid by the rules of the mapping.</p>
<p dir="auto">The problem arises when facets are run on fields that do not exist in the data, and thus are not "actually" in the mapping.</p>
<p dir="auto">Example : With a "dynamic_template" for "rating-*" fields, we can search, filter, and sort<br>
(with "ignore_unmapped" = true), against a "rating-Tuna" field, even though there are no<br>
documents in the index with that field.</p>
<p dir="auto">See Gist <a href="https://gist.github.com/4568689">https://gist.github.com/4568689</a> for a script that will quickly demonstrate the problem.</p>
<p dir="auto">Changing the routing value or parent id of a document will lead to duplicate documents with the same index, type, and id.  I <em>think</em> that internally a documents id is constructed from the index, type, id, and routing value so internally the id's are different, yet they look the same to the end user.</p>
<p dir="auto">Is there something we can do to address this?  Maybe add an "old_route" and "old_parent" flag that when found can be used to do issue a delete on the old shard?  Is there a better approach?</p>