elastic/elasticsearch · error · IllegalStateException
Cannot merge SEARCH_TIME and INDEX_TIME analysis mode.
Error message
Cannot merge SEARCH_TIME and INDEX_TIME analysis mode.
What it means
Thrown by AnalysisMode.INDEX_TIME.merge(other) when other == SEARCH_TIME. AnalysisMode models whether a token filter/analyzer component is allowed at index time, search time, both (ALL), or neither (NONE). Merging INDEX_TIME with SEARCH_TIME is impossible because a single component cannot be both exclusively-index and exclusively-search; the merge throws IllegalStateException to flag an inconsistent analyzer configuration.
Source
Thrown at libs/plugin-analysis-api/src/main/java/org/elasticsearch/plugin/analysis/AnalysisMode.java:26
*/
package org.elasticsearch.plugin.analysis;
/**
* Enum representing the mode in which token filters and analyzers are allowed to operate.
* While most token filters are allowed both in index and search time analyzers, some are
* restricted to be used only at index time, others at search time.
*/
public enum AnalysisMode {
/**
* AnalysisMode representing analysis components that can be used only at index time.
*/
INDEX_TIME("index time") {
@Override
public AnalysisMode merge(AnalysisMode other) {
if (other == AnalysisMode.SEARCH_TIME) {
throw new IllegalStateException("Cannot merge SEARCH_TIME and INDEX_TIME analysis mode.");
}
return AnalysisMode.INDEX_TIME;
}
},
/**
* AnalysisMode representing analysis components that can be used only at search time.
*/
SEARCH_TIME("search time") {
@Override
public AnalysisMode merge(AnalysisMode other) {
if (other == AnalysisMode.INDEX_TIME) {
throw new IllegalStateException("Cannot merge SEARCH_TIME and INDEX_TIME analysis mode.");
}
return AnalysisMode.SEARCH_TIME;
}
},
/**
* AnalysisMode representing analysis components that can be used both at index and search time.View on GitHub (pinned to db6a809a66)
Solutions
- Split the analyzer into separate index-time and search-time configurations so no single chain mixes INDEX_TIME and SEARCH_TIME components.
- Re-check each component's declared AnalysisMode and switch the offending one to ALL if it is genuinely usable at both phases.
- If you author the component, set AnalysisMode to match its real capabilities rather than over-restricting it.
- Validate the analyzer definition at config-load time and report which two filters conflict by name.
Example fix
// before: one analyzer mixes modes
"analysis": {
"analyzer": { "my": { "filter": ["index_only_syn", "search_only_norm"] } }
}
// after: separate analyzers per phase
"analysis": {
"analyzer": {
"my_index": { "filter": ["index_only_syn"] },
"my_search": { "filter": ["search_only_norm"] }
}
} Defensive patterns
Strategy: validation
Validate before calling
// Walk the analyzer's filter chain and reject conflicting AnalysisMode merges up front.
AnalysisMode acc = AnalysisMode.ALL;
for (AnalysisComponent c : filters) {
AnalysisMode m = c.analysisMode();
if ((acc == AnalysisMode.INDEX_TIME && m == AnalysisMode.SEARCH_TIME)
|| (acc == AnalysisMode.SEARCH_TIME && m == AnalysisMode.INDEX_TIME)) {
throw new IllegalArgumentException("Analyzer mixes INDEX_TIME and SEARCH_TIME filters: " + c.name());
}
acc = acc.merge(m);
} Try / catch
try {
AnalysisMode merged = a.merge(b);
} catch (IllegalStateException e) {
throw new IllegalArgumentException("Cannot build analyzer: index-only and search-only filters are incompatible", e);
} Prevention
- Split analyzers into index-time and search-time configurations.
- Default custom token filters to AnalysisMode.ALL unless they truly cannot run in one phase.
- Validate the filter chain at config-load time and report the conflicting pair.
When it happens
Trigger: A multi-component analyzer/filter chain where one component declares AnalysisMode.INDEX_TIME and another declares AnalysisMode.SEARCH_TIME, and the framework merges their modes to decide where the analyzer can run. E.g. a custom analyzer combining an index-only synonym filter with a search-only normalization filter.
Common situations: Adding a search-only filter (e.g. some stemmer variants) to an analyzer also used at index time, or vice-versa; plugin authors setting the wrong AnalysisMode on a token filter; upgrading a filter whose mode changed between versions.
Related errors
- synonym requires either `synonyms`, `synonyms_set` or `synon
- update_offsets is not supported anymore. Please fix your ana
- length parameter must be provided
- Token filter [{name()}] cannot be used to parse synonyms
- Token filter [{name()}] cannot be used to parse synonyms
AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12).
Data as JSON: /api/errors/53f9ba23282fc3f9.
Report an issue: GitHub.