# Filtered Query

**URL:** <https://discuss.elastic.co/t/filtered-query/13140>\
**Category:** Elasticsearch\
**Created:** [August 9, 2013, 5:05am UTC](https://discuss.elastic.co/t/filtered-query/13140 "2013-08-09T05:05:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Igal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igal/32/1119_2.png) [@Igal](https://discuss.elastic.co/u/Igal)\
**Post date:** [August 9, 2013, 5:05am UTC](https://discuss.elastic.co/t/filtered-query/13140/1 "2013-08-09T05:05:44Z")

</div>

hi all,

I am trying to add a filter to the following query:

{  
"query": {  
"query\_string": {  
"query": Q  
,"minimum\_should\_match": "3"  
}  
}  
,"facets": {  
"tags": {  
"terms": {  
"field": "tags"  
}  
}  
}  
}

I tried different variation, among which the one below, but I can't get  
it to work:

{  
"query": {  
"filtered": {

```
         "query": {
              "query_string": {
                    "query": Q
                  ,"minimum_should_match": "3"
             }
         }
         ,"filter": {
              "and" : [
                 { "tags": "red" }
              ]
         }
         ,"facets": {
              "tags": {
                  "terms": {
                     "field": "tags"
                 }
             }
         }
      }
 }

```

}

any ideas what I am doing wrong?

TIA,

Igal

--  
Igal Sapir  
Railo Core Developer  
[http://getRailo.org/](http://getRailo.org/)

--  
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:** ![narinder\_izap](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/narinder_izap/32/803_2.png) [@narinder\_izap](https://discuss.elastic.co/u/narinder_izap)\
**Post date:** [August 9, 2013, 6:38am UTC](https://discuss.elastic.co/t/filtered-query/13140/2 "2013-08-09T06:38:00Z")

</div>

Try this :

{  
"query": {  
"filtered": {  
"query": {  
"query\_string": {  
"query": "Q",  
"minimum\_should\_match": "3"  
}  
},  
"filter": {  
"and": [  
{  
"term": {  
"tags": "red"  
}  
}  
]  
}  
}  
}  
,"facets": {  
"tags": {  
"terms": {  
"field": "tags"  
}  
}  
}  
}

On Friday, 9 August 2013 10:35:44 UTC+5:30, Igal wrote:

> hi all,
> 
> I am trying to add a filter to the following query:
> 
> {  
> "query": {  
> "query\_string": {  
> "query": Q  
> ,"minimum\_should\_match": "3"  
> }  
> }  
> ,"facets": {  
> "tags": {  
> "terms": {  
> "field": "tags"  
> }  
> }  
> }  
> }
> 
> I tried different variation, among which the one below, but I can't get  
> it to work:
> 
> {  
> "query": {  
> "filtered": {
> 
> ```
> "query": { 
> "query_string": { 
> "query": Q 
> ,"minimum_should_match": "3" 
> } 
> } 
> ,"filter": { 
> "and" : [ 
> { "tags": "red" } 
> ] 
> } 
> ,"facets": { 
> "tags": { 
> "terms": { 
> "field": "tags" 
> } 
> } 
> } 
> } 
> } 
> 
> ```
> 
> }
> 
> any ideas what I am doing wrong?
> 
> TIA,
> 
> Igal
> 
> --  
> Igal Sapir  
> Railo Core Developer  
> [http://getRailo.org/](http://getRailo.org/)

--  
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:** ![Igal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igal/32/1119_2.png) [@Igal](https://discuss.elastic.co/u/Igal)\
**Post date:** [August 13, 2013, 4:55pm UTC](https://discuss.elastic.co/t/filtered-query/13140/3 "2013-08-13T16:55:58Z")

</div>

no one?

On 8/8/2013 10:05 PM, Igal @ [getRailo.org](http://getRailo.org) wrote:

> hi all,
> 
> I am trying to add a filter to the following query:
> 
> {  
> "query": {  
> "query\_string": {  
> "query": Q  
> ,"minimum\_should\_match": "3"  
> }  
> }  
> ,"facets": {  
> "tags": {  
> "terms": {  
> "field": "tags"  
> }  
> }  
> }  
> }
> 
> I tried different variation, among which the one below, but I can't  
> get it to work:
> 
> {  
> "query": {  
> "filtered": {
> 
> ```
> "query": {
> "query_string": {
> "query": Q
> ,"minimum_should_match": "3"
> }
> }
> ,"filter": {
> "and" : [
> { "tags": "red" }
> ]
> }
> ,"facets": {
> "tags": {
> "terms": {
> "field": "tags"
> }
> }
> }
> }
> }
> 
> ```
> 
> }
> 
> any ideas what I am doing wrong?
> 
> TIA,
> 
> Igal

--  
Igal Sapir  
Railo Core Developer

> **[Top 10 Best Bitcoin Slots Sites | Best Online Casino 2023](https://www.getrailo.org/)**
>
> Compare the Best Bitcoin Slots Sites now at getrailo.org. Slots represent some of the most popular and exciting online casino offerings.

--  
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:** [August 13, 2013, 6:49pm UTC](https://discuss.elastic.co/t/filtered-query/13140/4 "2013-08-13T18:49:23Z")

</div>

A full curl recreation on [gist.github.com](http://gist.github.com) could help us to better understand your concern and provide a solution.

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 13 août 2013 à 18:55, "Igal @ [getRailo.org](http://getRailo.org)" [igal@getrailo.org](mailto:igal@getrailo.org) a écrit :

no one?

On 8/8/2013 10:05 PM, Igal @ [getRailo.org](http://getRailo.org) wrote:

> hi all,
> 
> I am trying to add a filter to the following query:
> 
> {  
> "query": {  
> "query\_string": {  
> "query": Q  
> ,"minimum\_should\_match": "3"  
> }  
> }  
> ,"facets": {  
> "tags": {  
> "terms": {  
> "field": "tags"  
> }  
> }  
> }  
> }
> 
> I tried different variation, among which the one below, but I can't get it to work:
> 
> {  
> "query": {  
> "filtered": {
> 
> ```
> "query": {
> "query_string": {
> "query": Q
> ,"minimum_should_match": "3"
> }
> }
> ,"filter": {
> "and" : [
> { "tags": "red" }
> ]
> }
> ,"facets": {
> "tags": {
> "terms": {
> "field": "tags"
> }
> }
> }
> }
> 
> ```
> 
> }  
> }
> 
> any ideas what I am doing wrong?
> 
> TIA,
> 
> Igal

--  
Igal Sapir  
Railo Core Developer

> **[Top 10 Best Bitcoin Slots Sites | Best Online Casino 2023](https://www.getrailo.org/)**
>
> Compare the Best Bitcoin Slots Sites now at getrailo.org. Slots represent some of the most popular and exciting online casino offerings.

--  
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:** ![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:21am UTC](https://discuss.elastic.co/t/filtered-query/13140/5 "2017-07-06T02:21:18Z")

</div>

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


