Before you begin reading this guide, we recommend you try running the Elasticsearch Error Check-Up which can resolve issues that cause many errors.
This guide will help you check for common problems that cause the log ” Failed to generate ” + filter + ” ” to appear. It’s important to understand the issues related to the log, so to get started, read the general overview on common issues and tips related to the Elasticsearch concepts: admin, indices, alias and filter.
Advanced users might want to skip right to the common problems section in each concept or try running the Check-Up which analyses ES to pinpoint the cause of many errors and provides suitable actionable recommendations how to resolve them (free tool that requires no installation).
Overview
In Elasticsearch, an alias is a secondary name to refer to one or more indices. Aliases can be created and removed dynamically using _aliases REST endpoint.
What it is used for
Aliases are used for multiple purposes such as to search across more than one index with a single name, perform the reindexing process with zero downtime and query data based on predefined filters.
Examples
Creating an alias on a single index:
POST /_aliases?pretty { "actions": [ { "add": { "index": "index_1", "alias": "alias_1" } } ] }
Creating an alias that is tied to more than one index:
POST /_aliases?pretty { "actions": [ { "add": { "index": "index_1", "alias": "alias_1" } }, { "add": { "index": "index_2", "alias": "alias_1" } } ] }
Creating a filter-based alias:
POST /_aliases?pretty { "actions": [ { "add": { "index": "index_1", "alias": "alias_2", "filter": { "term": { "organization": "opster" } } } } ] }
Listing out all of the available aliases in an Elasticsearch cluster:
GET _cat/aliases
Removing an alias:
POST /_aliases?pretty { "actions": [ { "remove": { "index": "index_2", "alias": "alias_1" } } ] }
Notes
- An Alias cannot be used for the indexing process if it points to more than one index. If attempted, Elasticsearch will throw an exception.
- Deleting an alias does not delete the actual index.
Common problems
- Since a single alias can be attached to multiple indices, it is important to keep in mind that querying an alias will send the query against all the associated indices, which can impact the search performance and high resource utilization.
Log Context
Log”Failed to generate [” + filter + “]”classname is IndicesAliasesRequest.java We extracted the following from Elasticsearch source code for those seeking an in-depth context :
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); builder.map(filter); this.filter = Strings.toString(builder); return this; } catch (IOException e) { throw new ElasticsearchGenerationException("Failed to generate [" + filter + "]"; e); } } public AliasActions filter(QueryBuilder filter) { if (filter == null) {
Run the Check-Up to get customized recommendations like this:

Heavy merges detected in specific nodes

Description
A large number of small shards can slow down searches and cause cluster instability. Some indices have shards that are too small…

Recommendations Based on your specific ES deployment you should…
Based on your specific ES deployment you should…
X-PUT curl -H [a customized recommendation]