# OR filters

**URL:** <https://discuss.elastic.co/t/or-filters/13440>\
**Category:** Elasticsearch\
**Created:** [September 3, 2013, 9:31am UTC](https://discuss.elastic.co/t/or-filters/13440 "2013-09-03T09:31:56Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gaukhar\_Taspolatova](https://avatars.discourse-cdn.com/v4/letter/g/779978/32.png) [@Gaukhar\_Taspolatova](https://discuss.elastic.co/u/Gaukhar_Taspolatova)\
**Post date:** [September 3, 2013, 9:31am UTC](https://discuss.elastic.co/t/or-filters/13440/1 "2013-09-03T09:31:56Z")

</div>

Hi,  
Can anyone please explain to me how can I find people who's age is equal to  
30 OR 40? Field "age" can store only one value.  
First I tried to query as:  
"query" =\> [  
"match\_all" =\> []  
],  
"filter" =\> [  
"and" =\> [  
"filters" =\> [  
"term" =\> ["age" : [30, 40]]  
]  
]  
]  
Then I've changed it to  
'filtered' =\> ['query' =\> 'match\_all' =\>\*[]],

- \*\* ['filter' =\> [ 'and' =\>\*\*[ 'filters' =\> \*\*[ 'or' =\> \*\*[  
[0 =\> 'term' =\> 'age' =\> 30],  
[1 =\> 'term' =\> 'age' =\> 40]]]]]

I used filtered as I can have mutiple filters. this is just an example of  
one. None of this queries gives me what I want.  
Please help.

G.

--  
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:** ![Rafal\_Kuc\_3](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rafal_kuc_3/32/799_2.png) [@Rafal\_Kuc\_3](https://discuss.elastic.co/u/Rafal_Kuc_3)\
**Post date:** [September 3, 2013, 10:03am UTC](https://discuss.elastic.co/t/or-filters/13440/2 "2013-09-03T10:03:39Z")

</div>

Hello!

You can use an or filter to find documents with age field value equal to 30 or 40. For example, something like this should work:

{

"query" : {

"match\_all" : {}

},

"filter" : {

"or" : [

{

```
"term" : { "age" : 30 }

```

},

{

```
"term" : { "age" : 40}

```

}

]

}

}

_--_

Regards,

Rafał Kuć

Sematext :: [http://sematext.com/](http://sematext.com/) _:: Solr - Lucene - ElasticSearch_

Hi,

Can anyone please explain to me how can I find people who's age is equal to 30 OR 40? Field "age" can store only one value.

First I tried to query as:

"query" =\> [

"match\_all" =\> []

],

"filter" =\> [

"and" =\> [

```
 "filters" =&gt; [

     "term" =&gt; ["age" : [30, 40]]

 ]

```

]

]

Then I've changed it to

'filtered' =\> ['query' =\> 'match\_all' =\>_[]],_

['filter' =\> [ 'and' =\>[ 'filters' =\> [ 'or' =\> [

```
[0 =&gt; 'term' =&gt; 'age' =&gt; 30],

[1 =&gt; 'term' =&gt; 'age' =&gt; 40]]]]]

```

I used filtered as I can have mutiple filters. this is just an example of one. None of this queries gives me what I want.

Please help.

G.

--

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:** ![Gaukhar\_Taspolatova](https://avatars.discourse-cdn.com/v4/letter/g/779978/32.png) [@Gaukhar\_Taspolatova](https://discuss.elastic.co/u/Gaukhar_Taspolatova)\
**Post date:** [September 3, 2013, 10:09am UTC](https://discuss.elastic.co/t/or-filters/13440/3 "2013-09-03T10:09:25Z")

</div>

It's not what I want. There are more filters like the age filter. For  
example age = 30 or 40 AND status = employed OR partly employed AND so on...

On Tue, Sep 3, 2013 at 4:03 PM, Rafał Kuć [r.kuc@solr.pl](mailto:r.kuc@solr.pl) wrote:

> Hello!
> 
> You can use an or filter to find documents with age field value equal to  
> 30 or 40. For example, something like this should work:
> 
> {  
> "query" : {  
> "match\_all" : {}  
> },  
> "filter" : {  
> "or" : [  
> {  
> "term" : { "age" : 30 }  
> },  
> {  
> "term" : { "age" : 40}  
> }  
> ]  
> }  
> }
> 
> \*--  
> Regards,  
> Rafał Kuć  
> Sematext :: _[http://sematext.com/](http://sematext.com/)_ :: Solr - Lucene - Elasticsearch
> 
> - 
> 
> Hi,  
> Can anyone please explain to me how can I find people who's age is equal  
> to 30 OR 40? Field "age" can store only one value.  
> First I tried to query as:  
> "query" =\> [  
> "match\_all" =\>   
> ],  
> "filter" =\> [  
> "and" =\> [  
> "filters" =\> [  
> "term" =\> ["age" : [30, 40]]  
> ]  
> ]  
> ]  
> Then I've changed it to  
> 'filtered'  
> =\> ['query' =\> 'match\_all' =\>\*],
> 
> - ['filter' =\> [ 'and' =\>[ 'filters' =\> [ 'or' =\> [  
> [0 =\> 'term' =\> 'age' =\> 30],  
> [1 =\> 'term' =\> 'age' =\> 40]]]]]
> 
> I used filtered as I can have mutiple filters. this is just an example of  
> one. None of this queries gives me what I want.  
> Please help.
> 
> ## G.
> 
> 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 a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/mSo1AtT4b4A/unsubscribe](https://groups.google.com/d/topic/elasticsearch/mSo1AtT4b4A/unsubscribe).  
> To unsubscribe from this group and all its topics, 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).

--

\*С уважением, Best  
regards,  
Гаухар Тасполатова. Gaukhar  
Taspolatova. \*

--  
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:** ![Rafal\_Kuc\_3](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rafal_kuc_3/32/799_2.png) [@Rafal\_Kuc\_3](https://discuss.elastic.co/u/Rafal_Kuc_3)\
**Post date:** [September 3, 2013, 10:22am UTC](https://discuss.elastic.co/t/or-filters/13440/4 "2013-09-03T10:22:12Z")

</div>

Hello!

If there are multiple filters like this, just use an and filter and group filters for the same fields in the or filter clause. For example like this:

curl -XGET 'localhost:9200/\_search?pretty' -d '{

"query" : {

"match\_all" : {}

},

"filter" : {

"and" : [

{

```
"or" : [

 {

  "term" : {"age" : 30}

 },

 {

  "term" : {"age" : 40}

 }

]

```

},

{

```
"or" : [

 {

  "term" : {"year" : 2012}

 },

 {

  "term" : {"year" : 2013}

 }

]

```

}

]

}

}'

_--_

Regards,

Rafał Kuć

Sematext :: [http://sematext.com/](http://sematext.com/) _:: Solr - Lucene - ElasticSearch_

It's not what I want. There are more filters like the age filter. For example age = 30 or 40 AND status = employed OR partly employed AND so on...

On Tue, Sep 3, 2013 at 4:03 PM, Rafał Kuć \<[r.kuc@solr.pl](mailto:r.kuc@solr.pl)\> wrote:

Hello!

You can use an or filter to find documents with age field value equal to 30 or 40. For example, something like this should work:

{

"query" : {

"match\_all" : {}

},

"filter" : {

"or" : [

{

```
"term" : { "age" : 30 }

```

},

{

```
"term" : { "age" : 40}

```

}

]

}

}

_--_

Regards,

Rafał Kuć

Sematext :: [http://sematext.com/](http://sematext.com/) _:: Solr - Lucene - ElasticSearch_

Hi,

Can anyone please explain to me how can I find people who's age is equal to 30 OR 40? Field "age" can store only one value.

First I tried to query as:

"query" =\> [

"match\_all" =\> []

],

"filter" =\> [

"and" =\> [

```
 "filters" =&gt; [

     "term" =&gt; ["age" : [30, 40]]

 ]

```

]

]

Then I've changed it to

'filtered'

=\> ['query' =\> 'match\_all' =\>_[]],_

['filter' =\> [ 'and' =\>[ 'filters' =\> [ 'or' =\> [

```
[0 =&gt; 'term' =&gt; 'age' =&gt; 30],

[1 =&gt; 'term' =&gt; 'age' =&gt; 40]]]]]

```

I used filtered as I can have mutiple filters. this is just an example of one. None of this queries gives me what I want.

Please help.

G.

--

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%2Bunsubscribe@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 a topic in the Google Groups "elasticsearch" group.

To unsubscribe from this topic, visit [https://groups.google.com/d/topic/elasticsearch/mSo1AtT4b4A/unsubscribe](https://groups.google.com/d/topic/elasticsearch/mSo1AtT4b4A/unsubscribe).

To unsubscribe from this group and all its topics, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch%2Bunsubscribe@googlegroups.com).

For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--

_С уважением, Best regards,_

Гаухар Тасполатова. Gaukhar Taspolatova.

--

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:** ![Gaukhar\_Taspolatova](https://avatars.discourse-cdn.com/v4/letter/g/779978/32.png) [@Gaukhar\_Taspolatova](https://discuss.elastic.co/u/Gaukhar_Taspolatova)\
**Post date:** [September 3, 2013, 10:59am UTC](https://discuss.elastic.co/t/or-filters/13440/5 "2013-09-03T10:59:02Z")

</div>

ok, thanks. will try. hope it'll work.

On Tue, Sep 3, 2013 at 4:22 PM, Rafał Kuć [r.kuc@solr.pl](mailto:r.kuc@solr.pl) wrote:

> Hello!
> 
> If there are multiple filters like this, just use an and filter and group  
> filters for the same fields in the or filter clause. For example like this:
> 
> curl -XGET 'localhost:9200/\_search?pretty' -d '{  
> "query" : {  
> "match\_all" : {}  
> },  
> "filter" : {  
> "and" : [
> 
> {  
> "or" : [  
> {  
> "term" : {"age" : 30}  
> },  
> {  
> "term" : {"age" : 40}  
> }  
> ]  
> },  
> {  
> "or" : [  
> {  
> "term" : {"year" : 2012}  
> },  
> {  
> "term" : {"year" : 2013}  
> }  
> ]  
> }  
> ]
> 
> }  
> }'
> 
> _--  
> Regards,  
> Rafał Kuć  
> Sematext :: \*  
> [http://sematext.com/](http://sematext.com/)_ :: Solr - Lucene - Elasticsearch
> 
> - 
> 
> It's not what I want. There are more filters like the age filter. For  
> example age = 30 or 40 AND status = employed OR partly employed AND so on...
> 
> On Tue, Sep 3, 2013 at 4:03 PM, Rafał Kuć [r.kuc@solr.pl](mailto:r.kuc@solr.pl) wrote:  
> Hello!
> 
> You can use an or filter to find documents with age field value equal to  
> 30 or 40. For example, something like this should work:
> 
> {  
> "query" : {  
> "match\_all" : {}  
> },  
> "filter" : {  
> "or" : [  
> {  
> "term" : { "age" : 30 }  
> },  
> {  
> "term" : { "age" : 40}  
> }  
> ]  
> }  
> }
> 
> \*--  
> Regards,  
> Rafał Kuć  
> Sematext :: _[http://sematext.com/](http://sematext.com/)_ :: Solr - Lucene - Elasticsearch
> 
> - 
> 
> Hi,  
> Can anyone please explain to me how can I find people who's age is equal  
> to 30 OR 40? Field "age" can store only one value.  
> First I tried to query as:  
> "query" =\> [  
> "match\_all" =\>   
> ],  
> "filter" =\> [  
> "and" =\> [  
> "filters" =\> [  
> "term" =\> ["age" : [30, 40]]  
> ]  
> ]  
> ]  
> Then I've changed it to  
> 'filtered'  
> =\> ['query' =\> 'match\_all' =\>\*],
> 
> - ['filter' =\> [ 'and' =\>[ 'filters' =\> [ 'or' =\> [  
> [0 =\> 'term' =\> 'age' =\> 30],  
> [1 =\> 'term' =\> 'age' =\> 40]]]]]
> 
> I used filtered as I can have mutiple filters. this is just an example of  
> one. None of this queries gives me what I want.  
> Please help.
> 
> ## G.
> 
> 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 a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/mSo1AtT4b4A/unsubscribe](https://groups.google.com/d/topic/elasticsearch/mSo1AtT4b4A/unsubscribe).  
> To unsubscribe from this group and all its topics, 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).
> 
> --
> 
> \*С уважением,  
> Best regards,  
> Гаухар Тасполатова. Gaukhar  
> Taspolatova.
> 
> - 
> 
> --  
> 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 a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/mSo1AtT4b4A/unsubscribe](https://groups.google.com/d/topic/elasticsearch/mSo1AtT4b4A/unsubscribe).  
> To unsubscribe from this group and all its topics, 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).

--

\*С уважением, Best  
regards,  
Гаухар Тасполатова. Gaukhar  
Taspolatova. \*

--  
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:** ![Rafal\_Kuc\_3](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rafal_kuc_3/32/799_2.png) [@Rafal\_Kuc\_3](https://discuss.elastic.co/u/Rafal_Kuc_3)\
**Post date:** [September 3, 2013, 12:11pm UTC](https://discuss.elastic.co/t/or-filters/13440/6 "2013-09-03T12:11:07Z")

</div>

Hello!

I've created a simple gist with sample data, so you can look at the data, query and ES response: [https://gist.github.com/gr0/6422143](https://gist.github.com/gr0/6422143)

_--_

Regards,

Rafał Kuć

Sematext :: [http://sematext.com/](http://sematext.com/) _:: Solr - Lucene - ElasticSearch_

ok, thanks. will try. hope it'll work.

On Tue, Sep 3, 2013 at 4:22 PM, Rafał Kuć \<[r.kuc@solr.pl](mailto:r.kuc@solr.pl)\> wrote:

Hello!

If there are multiple filters like this, just use an and filter and group filters for the same fields in the or filter clause. For example like this:

curl -XGET 'localhost:9200/\_search?pretty' -d '{

"query" : {

"match\_all" : {}

},

"filter" : {

"and" : [

{

```
"or" : [

 {

  "term" : {"age" : 30}

 },

 {

  "term" : {"age" : 40}

 }

]

```

},

{

```
"or" : [

 {

  "term" : {"year" : 2012}

 },

 {

  "term" : {"year" : 2013}

 }

]

```

}

]

}

}'

_--_

Regards,

Rafał Kuć

Sematext ::

[http://sematext.com/](http://sematext.com/) _:: Solr - Lucene - ElasticSearch_

It's not what I want. There are more filters like the age filter. For example age = 30 or 40 AND status = employed OR partly employed AND so on...

On Tue, Sep 3, 2013 at 4:03 PM, Rafał Kuć \<[r.kuc@solr.pl](mailto:r.kuc@solr.pl)\> wrote:

Hello!

You can use an or filter to find documents with age field value equal to 30 or 40. For example, something like this should work:

{

"query" : {

"match\_all" : {}

},

"filter" : {

"or" : [

{

```
"term" : { "age" : 30 }

```

},

{

```
"term" : { "age" : 40}

```

}

]

}

}

_--_

Regards,

Rafał Kuć

Sematext :: [http://sematext.com/](http://sematext.com/) _:: Solr - Lucene - ElasticSearch_

Hi,

Can anyone please explain to me how can I find people who's age is equal to 30 OR 40? Field "age" can store only one value.

First I tried to query as:

"query" =\> [

"match\_all" =\> []

],

"filter" =\> [

"and" =\> [

```
 "filters" =&gt; [

     "term" =&gt; ["age" : [30, 40]]

 ]

```

]

]

Then I've changed it to

'filtered'

=\> ['query' =\> 'match\_all' =\>_[]],_

['filter' =\> [ 'and' =\>[ 'filters' =\> [ 'or' =\> [

```
[0 =&gt; 'term' =&gt; 'age' =&gt; 30],

[1 =&gt; 'term' =&gt; 'age' =&gt; 40]]]]]

```

I used filtered as I can have mutiple filters. this is just an example of one. None of this queries gives me what I want.

Please help.

G.

--

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%2Bunsubscribe@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 a topic in the Google Groups "elasticsearch" group.

To unsubscribe from this topic, visit [https://groups.google.com/d/topic/elasticsearch/mSo1AtT4b4A/unsubscribe](https://groups.google.com/d/topic/elasticsearch/mSo1AtT4b4A/unsubscribe).

To unsubscribe from this group and all its topics, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch%2Bunsubscribe@googlegroups.com).

For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--

_С уважением, Best regards,_

Гаухар Тасполатова. Gaukhar Taspolatova.

--

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%2Bunsubscribe@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 a topic in the Google Groups "elasticsearch" group.

To unsubscribe from this topic, visit [https://groups.google.com/d/topic/elasticsearch/mSo1AtT4b4A/unsubscribe](https://groups.google.com/d/topic/elasticsearch/mSo1AtT4b4A/unsubscribe).

To unsubscribe from this group and all its topics, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch%2Bunsubscribe@googlegroups.com).

For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--

_С уважением, Best regards,_

Гаухар Тасполатова. Gaukhar Taspolatova.

--

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:** ![Gaukhar\_Taspolatova](https://avatars.discourse-cdn.com/v4/letter/g/779978/32.png) [@Gaukhar\_Taspolatova](https://discuss.elastic.co/u/Gaukhar_Taspolatova)\
**Post date:** [September 4, 2013, 10:24am UTC](https://discuss.elastic.co/t/or-filters/13440/7 "2013-09-04T10:24:43Z")

</div>

Hi, thanks for the help! and the example. seems it's working for me as  
well, just needed some time to write the query right.

I have another question, if you dont mind.  
I have facets, & one of the fields can have around 100 different values. I  
set "size" to 100, but now it takes longer to get the results. Can you  
suggest something to fix this issue?

G.

On Tue, Sep 3, 2013 at 6:11 PM, Rafał Kuć [r.kuc@solr.pl](mailto:r.kuc@solr.pl) wrote:

> Hello!
> 
> I've created a simple gist with sample data, so you can look at the data,  
> query and ES response: [Simple usage of AND and OR filters combined in ElasticSearch. · GitHub](https://gist.github.com/gr0/6422143)
> 
> \*--  
> Regards,  
> Rafał Kuć  
> Sematext :: _[http://sematext.com/](http://sematext.com/)_ :: Solr - Lucene - Elasticsearch
> 
> - 
> 
> ok, thanks. will try. hope it'll work.
> 
> On Tue, Sep 3, 2013 at 4:22 PM, Rafał Kuć [r.kuc@solr.pl](mailto:r.kuc@solr.pl) wrote:  
> Hello!
> 
> If there are multiple filters like this, just use an and filter and group  
> filters for the same fields in the or filter clause. For example like this:
> 
> curl -XGET 'localhost:9200/\_search?pretty' -d '{  
> "query" : {  
> "match\_all" : {}  
> },  
> "filter" : {  
> "and" : [
> 
> {  
> "or" : [  
> {  
> "term" : {"age" : 30}  
> },  
> {  
> "term" : {"age" : 40}  
> }  
> ]  
> },  
> {  
> "or" : [  
> {  
> "term" : {"year" : 2012}  
> },  
> {  
> "term" : {"year" : 2013}  
> }  
> ]  
> }  
> ]
> 
> }  
> }'
> 
> \*--  
> Regards,  
> Rafał Kuć  
> Sematext ::  
> _[http://sematext.com/](http://sematext.com/)_ :: Solr - Lucene - Elasticsearch
> 
> - 
> 
> It's not what I want. There are more filters like the age filter. For  
> example age = 30 or 40 AND status = employed OR partly employed AND so on...
> 
> On Tue, Sep 3, 2013 at 4:03 PM, Rafał Kuć [r.kuc@solr.pl](mailto:r.kuc@solr.pl) wrote:  
> Hello!
> 
> You can use an or filter to find documents with age field value equal to  
> 30 or 40. For example, something like this should work:
> 
> {  
> "query" : {  
> "match\_all" : {}  
> },  
> "filter" : {  
> "or" : [  
> {  
> "term" : { "age" : 30 }  
> },  
> {  
> "term" : { "age" : 40}  
> }  
> ]  
> }  
> }
> 
> \*--  
> Regards,  
> Rafał Kuć  
> Sematext :: _[http://sematext.com/](http://sematext.com/)_ :: Solr - Lucene - Elasticsearch
> 
> - 
> 
> Hi,  
> Can anyone please explain to me how can I find people who's age is equal  
> to 30 OR 40? Field "age" can store only one value.  
> First I tried to query as:  
> "query" =\> [  
> "match\_all" =\>   
> ],  
> "filter" =\> [  
> "and" =\> [  
> "filters" =\> [  
> "term" =\> ["age" : [30, 40]]  
> ]  
> ]  
> ]  
> Then I've changed it to  
> 'filtered'  
> =\> ['query' =\> 'match\_all' =\>\*],
> 
> - ['filter' =\> [ 'and' =\>[ 'filters' =\> [ 'or' =\> [  
> [0 =\> 'term' =\> 'age' =\> 30],  
> [1 =\> 'term' =\> 'age' =\> 40]]]]]
> 
> I used filtered as I can have mutiple filters. this is just an example of  
> one. None of this queries gives me what I want.  
> Please help.
> 
> ## G.
> 
> 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 a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/mSo1AtT4b4A/unsubscribe](https://groups.google.com/d/topic/elasticsearch/mSo1AtT4b4A/unsubscribe).  
> To unsubscribe from this group and all its topics, 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).
> 
> --
> 
> \*С уважением,  
> Best regards,  
> Гаухар Тасполатова. Gaukhar  
> Taspolatova.
> 
> - 
> 
> --  
> 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 a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/mSo1AtT4b4A/unsubscribe](https://groups.google.com/d/topic/elasticsearch/mSo1AtT4b4A/unsubscribe).  
> To unsubscribe from this group and all its topics, 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).
> 
> --
> 
> \*С уважением,  
> Best regards,  
> Гаухар Тасполатова. Gaukhar  
> Taspolatova.
> 
> - 
> 
> --  
> 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 a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/mSo1AtT4b4A/unsubscribe](https://groups.google.com/d/topic/elasticsearch/mSo1AtT4b4A/unsubscribe).  
> To unsubscribe from this group and all its topics, 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).

--

\*С уважением, Best  
regards,  
Гаухар Тасполатова. Gaukhar  
Taspolatova. \*

--  
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:** ![Borislav\_Gankov](https://avatars.discourse-cdn.com/v4/letter/b/b5ac83/32.png) [@Borislav\_Gankov](https://discuss.elastic.co/u/Borislav_Gankov)\
**Post date:** [September 4, 2013, 12:29pm UTC](https://discuss.elastic.co/t/or-filters/13440/8 "2013-09-04T12:29:30Z")

</div>

Hi,

See if that helps:

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

> 

Rgds,  
Borislav

--  
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:** ![Gaukhar\_Taspolatova](https://avatars.discourse-cdn.com/v4/letter/g/779978/32.png) [@Gaukhar\_Taspolatova](https://discuss.elastic.co/u/Gaukhar_Taspolatova)\
**Post date:** [September 4, 2013, 12:50pm UTC](https://discuss.elastic.co/t/or-filters/13440/9 "2013-09-04T12:50:46Z")

</div>

Thanks!

On Wed, Sep 4, 2013 at 6:29 PM, Borislav Gankov [bgankov@gmail.com](mailto:bgankov@gmail.com) wrote:

> Hi,
> 
> See if that helps:  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/blog/all-about-elasticsearch-filter-bitsets/)
> 
> > 
> 
> Rgds,  
> Borislav
> 
> --  
> You received this message because you are subscribed to a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/mSo1AtT4b4A/unsubscribe](https://groups.google.com/d/topic/elasticsearch/mSo1AtT4b4A/unsubscribe).  
> To unsubscribe from this group and all its topics, 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).

--

\*С уважением, Best  
regards,  
Гаухар Тасполатова. Gaukhar  
Taspolatova. \*

--  
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:18am UTC](https://discuss.elastic.co/t/or-filters/13440/10 "2017-07-06T02:18:14Z")

</div>


