OR filters

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.
For more options, visit https://groups.google.com/groups/opt_out.

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/ :: 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.

For more options, visit https://groups.google.com/groups/opt_out.

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 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/ :: 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.
For more options, visit 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.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.
For more options, visit 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.
For more options, visit https://groups.google.com/groups/opt_out.

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/ :: 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> 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/ :: 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.

For more options, visit 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.

To unsubscribe from this group and all its topics, send an email to elasticsearch+unsubscribe@googlegroups.com.

For more options, visit 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.

For more options, visit https://groups.google.com/groups/opt_out.

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

On Tue, Sep 3, 2013 at 4:22 PM, Rafał Kuć 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/
:: 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 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/ :: 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.
For more options, visit 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.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.
For more options, visit 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.
For more options, visit 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.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.
For more options, visit 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.
For more options, visit https://groups.google.com/groups/opt_out.

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

--

Regards,

Rafał Kuć

Sematext :: 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> 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/ :: 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> 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/ :: 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.

For more options, visit 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.

To unsubscribe from this group and all its topics, send an email to elasticsearch+unsubscribe@googlegroups.com.

For more options, visit 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.

For more options, visit 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.

To unsubscribe from this group and all its topics, send an email to elasticsearch+unsubscribe@googlegroups.com.

For more options, visit 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.

For more options, visit https://groups.google.com/groups/opt_out.

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 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

*--
Regards,
Rafał Kuć
Sematext :: 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 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/ :: 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 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/ :: 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.
For more options, visit 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.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.
For more options, visit 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.
For more options, visit 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.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.
For more options, visit 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.
For more options, visit 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.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.
For more options, visit 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.
For more options, visit https://groups.google.com/groups/opt_out.

Hi,

See if that helps:

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.
For more options, visit https://groups.google.com/groups/opt_out.

Thanks!

On Wed, Sep 4, 2013 at 6:29 PM, Borislav Gankov bgankov@gmail.com wrote:

Hi,

See if that helps:
Elasticsearch Platform — Find real-time answers at scale | Elastic

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.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.
For more options, visit 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.
For more options, visit https://groups.google.com/groups/opt_out.