# Match query in a filter

**URL:** <https://discuss.elastic.co/t/match-query-in-a-filter/12910>\
**Category:** Elasticsearch\
**Created:** [July 23, 2013, 8:55pm UTC](https://discuss.elastic.co/t/match-query-in-a-filter/12910 "2013-07-23T20:55:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stefanie](https://avatars.discourse-cdn.com/v4/letter/s/fbc32d/32.png) [@Stefanie](https://discuss.elastic.co/u/Stefanie)\
**Post date:** [July 23, 2013, 8:55pm UTC](https://discuss.elastic.co/t/match-query-in-a-filter/12910/1 "2013-07-23T20:55:48Z")

</div>

I am working on translating a match query into a filter and was not having  
a problem until I added a type.

My query looks like this and runs fine:

curl -X GET '[http://localhost:9200/u1/\_search?from=0&size=20&pretty](http://localhost:9200/u1/_search?from=0&size=20&pretty)' -d '{  
"query": {  
"match": {  
"\_all": "T-mobile",  
"type": "phrase"  
}  
},  
"size": 20,  
"from": 0  
}'

but when I try to run it as a filter like this:

curl -X GET '[http://localhost:9200/u1/\_search?from=0&size=20&pretty](http://localhost:9200/u1/_search?from=0&size=20&pretty)' -d '{  
"filter": {  
"query": {  
"match": {  
"\_all": "T-mobile",  
"type": "phrase"  
}  
}  
},  
"size": 20,  
"from": 0  
}'

I get the following error:

QueryParsingException[[statuses] [match] query parsed in simplified form,  
with direct field name, but included more options than just the field name,  
possibly use its 'options' form, with 'query' element?]

This only happens once I add the type option. Can I not do this in filters?

Thank you,  
Stefanie

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [July 24, 2013, 1:33pm UTC](https://discuss.elastic.co/t/match-query-in-a-filter/12910/2 "2013-07-24T13:33:28Z")

</div>

Hey,

your query seems not to be constructed correctly (see  
[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/match-query/))

Either you do (the field name opens a new JSON object containing query and  
type):

"query" : { "match" : { "\_all": { "query":"T-Mobile", "type":"phrase" } } }

or you do the short version

"query" : { "match\_phrase" : { "\_all": "T-Mobile" } }

Hope this helps

--Alex

On Tue, Jul 23, 2013 at 10:55 PM, Stefanie [stefanie@backstit.ch](mailto:stefanie@backstit.ch) wrote:

> I am working on translating a match query into a filter and was not having  
> a problem until I added a type.
> 
> My query looks like this and runs fine:
> 
> curl -X GET '[http://localhost:9200/u1/\_search?from=0&size=20&pretty](http://localhost:9200/u1/_search?from=0&size=20&pretty)' -d '{  
> "query": {  
> "match": {  
> "\_all": "T-mobile",  
> "type": "phrase"  
> }  
> },  
> "size": 20,  
> "from": 0  
> }'
> 
> but when I try to run it as a filter like this:
> 
> curl -X GET '[http://localhost:9200/u1/\_search?from=0&size=20&pretty](http://localhost:9200/u1/_search?from=0&size=20&pretty)' -d '{  
> "filter": {  
> "query": {  
> "match": {  
> "\_all": "T-mobile",  
> "type": "phrase"  
> }  
> }  
> },  
> "size": 20,  
> "from": 0  
> }'
> 
> I get the following error:
> 
> QueryParsingException[[statuses] [match] query parsed in simplified form,  
> with direct field name, but included more options than just the field name,  
> possibly use its 'options' form, with 'query' element?]
> 
> This only happens once I add the type option. Can I not do this in  
> filters?
> 
> Thank you,  
> Stefanie
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Stefanie](https://avatars.discourse-cdn.com/v4/letter/s/fbc32d/32.png) [@Stefanie](https://discuss.elastic.co/u/Stefanie)\
**Post date:** [July 24, 2013, 8:38pm UTC](https://discuss.elastic.co/t/match-query-in-a-filter/12910/3 "2013-07-24T20:38:01Z")

</div>

Thank you. Thank is what I was doing wrong.

Stefanie

On Tuesday, July 23, 2013 4:55:48 PM UTC-4, Stefanie wrote:

> I am working on translating a match query into a filter and was not having  
> a problem until I added a type.
> 
> My query looks like this and runs fine:
> 
> curl -X GET '[http://localhost:9200/u1/\_search?from=0&size=20&pretty](http://localhost:9200/u1/_search?from=0&size=20&pretty)' -d '{  
> "query": {  
> "match": {  
> "\_all": "T-mobile",  
> "type": "phrase"  
> }  
> },  
> "size": 20,  
> "from": 0  
> }'
> 
> but when I try to run it as a filter like this:
> 
> curl -X GET '[http://localhost:9200/u1/\_search?from=0&size=20&pretty](http://localhost:9200/u1/_search?from=0&size=20&pretty)' -d '{  
> "filter": {  
> "query": {  
> "match": {  
> "\_all": "T-mobile",  
> "type": "phrase"  
> }  
> }  
> },  
> "size": 20,  
> "from": 0  
> }'
> 
> I get the following error:
> 
> QueryParsingException[[statuses] [match] query parsed in simplified form,  
> with direct field name, but included more options than just the field name,  
> possibly use its 'options' form, with 'query' element?]
> 
> This only happens once I add the type option. Can I not do this in  
> filters?
> 
> Thank you,  
> Stefanie

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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 6, 2017, 2:24am UTC](https://discuss.elastic.co/t/match-query-in-a-filter/12910/4 "2017-07-06T02:24:41Z")

</div>


