# ElasticSearch filtered query match\_all

**URL:** <https://discuss.elastic.co/t/elasticsearch-filtered-query-match-all/11634>\
**Category:** Elasticsearch\
**Created:** [April 18, 2013, 5:03pm UTC](https://discuss.elastic.co/t/elasticsearch-filtered-query-match-all/11634 "2013-04-18T17:03:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andy\_Bajka\_2](https://avatars.discourse-cdn.com/v4/letter/a/e19adc/32.png) [@Andy\_Bajka\_2](https://discuss.elastic.co/u/Andy_Bajka_2)\
**Post date:** [April 18, 2013, 5:03pm UTC](https://discuss.elastic.co/t/elasticsearch-filtered-query-match-all/11634/1 "2013-04-18T17:03:38Z")

</div>

I'm getting matches on the date field and the post.user field, I wish to  
only get matches on the post.user field. I assume it might have something  
to do with the match\_all but I don't know.

Mapping

"xenforo113" : {  
"post" : {  
"\_source" : {  
"enabled" : false  
},  
"properties" : {  
"date" : {  
"type" : "long",  
"store" : "yes"  
},  
"discussion\_id" : {  
"type" : "long",  
"store" : "yes"  
},  
"message" : {  
"type" : "string"  
},  
"node" : {  
"type" : "long"  
},  
"thread" : {  
"type" : "long"  
},  
"title" : {  
"type" : "string"  
},  
"user" : {  
"type" : "long",  
"store" : "yes"  
}  
}  
}

Query

$data\_string = '{  
"from" : 0, "size" : 200,  
"sort" : [  
{ "date" : {"order" : "desc"} }  
],  
"query": {  
"filtered": {  
"query": {  
"match\_all": {  
}  
},  
"filter": {  
"bool": {  
"must": {  
"term": {  
"post.user": "' . $user\_id . '"  
}  
},  
"must\_not": {  
"range": {  
"node": {  
"from": 100,  
"to": 100  
}  
}  
}  
}  
}  
}  
}  
}';

How would I modify this query so I get results on only the post.user field?

Thank you.

--  
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:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 21, 2013, 12:30pm UTC](https://discuss.elastic.co/t/elasticsearch-filtered-query-match-all/11634/2 "2013-04-21T12:30:24Z")

</div>

Can you post a full curl recreation? Which document is supposed to match?  
I don't see anything weird in your query.

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 18 avr. 2013 à 19:03, Andy Bajka [andybajka2012@gmail.com](mailto:andybajka2012@gmail.com) a écrit :

> I'm getting matches on the date field and the post.user field, I wish to only get matches on the post.user field. I assume it might have something to do with the match\_all but I don't know.
> 
> Mapping
> 
> "xenforo113" : {  
> "post" : {  
> "\_source" : {  
> "enabled" : false  
> },  
> "properties" : {  
> "date" : {  
> "type" : "long",  
> "store" : "yes"  
> },  
> "discussion\_id" : {  
> "type" : "long",  
> "store" : "yes"  
> },  
> "message" : {  
> "type" : "string"  
> },  
> "node" : {  
> "type" : "long"  
> },  
> "thread" : {  
> "type" : "long"  
> },  
> "title" : {  
> "type" : "string"  
> },  
> "user" : {  
> "type" : "long",  
> "store" : "yes"  
> }  
> }  
> }
> 
> Query
> 
> $data\_string = '{  
> "from" : 0, "size" : 200,  
> "sort" : [  
> { "date" : {"order" : "desc"} }  
> ],  
> "query": {  
> "filtered": {  
> "query": {  
> "match\_all": {  
> }  
> },  
> "filter": {  
> "bool": {  
> "must": {  
> "term": {  
> "post.user": "' . $user\_id . '"  
> }  
> },  
> "must\_not": {  
> "range": {  
> "node": {  
> "from": 100,  
> "to": 100  
> }  
> }  
> }  
> }  
> }  
> }  
> }  
> }';
> 
> How would I modify this query so I get results on only the post.user field?
> 
> Thank you.
> 
> --  
> 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:40am UTC](https://discuss.elastic.co/t/elasticsearch-filtered-query-match-all/11634/3 "2017-07-06T02:40:17Z")

</div>

Closed on July 6, 2017, 2:40am UTC


