# No \[query\] registered for \[filtered\]

**URL:** <https://discuss.elastic.co/t/no-query-registered-for-filtered/64635>\
**Category:** Elasticsearch\
**Created:** [November 1, 2016, 8:55pm UTC](https://discuss.elastic.co/t/no-query-registered-for-filtered/64635 "2016-11-01T20:55:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AndyB](https://avatars.discourse-cdn.com/v4/letter/a/96bed5/32.png) [@AndyB](https://discuss.elastic.co/u/AndyB)\
**Post date:** [November 1, 2016, 8:55pm UTC](https://discuss.elastic.co/t/no-query-registered-for-filtered/64635/1 "2016-11-01T20:55:06Z")

</div>

My code was running fine on ElasticSearch v2x. But upgrading to ElasticSearch v5.0.0 I get the following error when I output the results:

```auto
PHP {
  "error" : {
    "root_cause" : [
      {
        "type" : "parsing_exception",
        "reason" : "no [query] registered for [filtered]",
        "line" : 4,
        "col" : 20
      }
    ],
    "type" : "parsing_exception",
    "reason" : "no [query] registered for [filtered]",
    "line" : 4,
    "col" : 20
  },
  "status" : 400
}
```

Here's my actual PHP code:

```auto
$data_string = '{
    "from" : 0, "size" : "' . $maximumResults . '",
    "query" : {
        "filtered" : {
            "query" : {
                "match" : {
                    "title" : {
                        "query" : "' . $searchWord1 . ' ' . $searchWord2 . ' ' . $searchWord3 . '",
                        "operator" : "and"
                    }
                }
            },
            "filter" : {
                "bool" : {
                    "must" : [
                    {
                        "term" : {
                            "node" : "' . $currentNodeId . '"
                        }
                    }
                    ],
                    "must_not" : {
                        "term" : {
                            "discussion_id" : "' . $currentThreadId . '"
                        }
                    }                                        
                }
            }
        }
    },
    "sort": { 
        "date": {"order": "desc" }
    }                        
}';

curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);

curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
'Content-Type: application/json',                                                                                
'Content-Length: ' . strlen($data_string))                                                                       
); 
 
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string );
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');

$results = curl_exec($ch);
```

---

<div class="post-metadata">

**Author:** ![cbuescher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cbuescher/32/60402_2.png) [@cbuescher](https://discuss.elastic.co/u/cbuescher)\
**Post date:** [November 1, 2016, 9:06pm UTC](https://discuss.elastic.co/t/no-query-registered-for-filtered/64635/2 "2016-11-01T21:06:05Z")

</div>

Hi,

the `filtered` query was deprecated in 2.0 and removed in 5.0. You can achieve the same using the `filter` section of a `bool` query as explained [here](https://www.elastic.co/guide/en/elasticsearch/reference/5.0/query-dsl-filtered-query.html).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 10:07pm UTC](https://discuss.elastic.co/t/no-query-registered-for-filtered/64635/3 "2017-07-05T22:07:42Z")

</div>


