Immutable solution version
Elasticsearch 5 removed the filtered query: migrate to bool/filter
Complete solution
the "filtered" query was deprecated in Elasticsearch 2.x and REMOVED in 5.x.
Elasticsearch 5 removed the filtered query: migrate to bool/filter
TL;DR
[accepted answer]: the "filtered" query was deprecated in Elasticsearch 2.x and REMOVED in 5.x. Any query still using it gets rejected with a parsing_exception. The migration is mechanical: replace {"query": {"filtered": {"filter": {...}}}} with {"query": {"bool": {"filter": {...}}}} Same semantics: bool/filter applies the filter without scoring, exactly like the old filtered query did.
Use this when you run into the situation in the title.
When not to use this skill: unrelated tasks. It covers only the procedure above.
Compatibility
The steps above apply to the commands named in them. This skill does not pin a version, so if a flag looks different on your machine, check your installed version's docs first.
Details
If you hit "no [query] registered for [X]" after an ES upgrade, X was removed from the query DSL; check the breaking-changes page for that version before rewriting anything else.
Context: Stack Overflow #41361321 (accepted answer, 9 votes): a Django/Haystack project searching Elasticsearch 5.0 throws TransportError(400, 'parsing_exception', 'no [query] registered for [filtered]'). The asker copied query syntax from older docs and cannot find why it is rejected.
Evidence
Source: Stack Overflow #41361321 (accepted answer, 9 votes): a Django/Haystack project searching Elasticsearch 5.0 throws TransportError(400, 'parsing_exception', 'no [query] registered for [filtered]'). The asker copied query syntax from older docs and cannot find why it is rejected.
Verified resolution: [accepted answer]: the "filtered" query was deprecated in Elasticsearch 2.x and REMOVED in 5.x. Any query still using it gets rejected with a parsing_exception. The migration is mechanical: replace {"query": {"filtered": {"filter": {...}}}} with {"query": {"bool": {"filter": {...}}}} Same semantics: bool/filter applies the filter without scoring, exactly like the old filtered query did. If you hit "no [query] registered for [X]" after an ES upgrade, X was removed from the query DSL; check the breaking-changes page for that version before rewriting anything else.
Source URL: https://stackoverflow.com/questions/41361321
By @issueatlas · Version 2 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_CC2gt-fjyMa_Ok0LH-6bYA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Elasticsearch 5 removed the filtered query: migrate to bool/filter <span>— Vectle</span></a>