Started to migrate our system to ES 6/7 single type and having some troubles i need assistance with.
We have a system which makes use of mustache templates and we query (before migration) a type along with a template and parameters, now when migrating to a single type I've added our previously type into a new field _docType to our documents and now to get this running I must in every template add a term-filter for _docType, and this is the part I don't like. I don't want to remember to add this in each new template that is written and would like to make use of URI-query to always append a filter for _docType ie. /_search/template?q=_docType:SomeType.
Problem with this is that if I have a "query"-clause in my template it's not getting applied, the URI query takes precedence.
You could also use a filtered alias to achieve the same thing. That wouldn't change your query at all, but instead of querying your index, you'd query the filtered alias
# create your filtered alias
POST /_aliases
{
"actions" : [
{
"add" : {
"index" : "your-index",
"alias" : "your-alias",
"filter" : { "term" : { "_docType" : "SomeType" } }
}
}
]
}
# 2. query the alias instead of the index
GET your-alias/_search?q=...
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.