# 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.
