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" => [
"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.