Can I combine documents matching different criteria in one query


(Asif) #1

Hi,
I want to search documents that match either of two following twi
criteria:

documents that have string term "test" in their content field

OR

document having timestamp say "2012-08-30T09:39:14"

I understand that if I wanted to do an AND it would be possible using *bool
*and *must *clause; but, I can't understand OR case.

Thanks

--


(phill) #2

Look at a should clause, that is the equivalent of "OR".
http://www.elasticsearch.org/guide/reference/query-dsl/bool-query.html
"A boolean query with no |must| clauses, one or more |should| clauses
must match a document. "

-Paul

On 9/5/2012 7:34 AM, Asif wrote:

Hi,
I want to search documents that match either of two following twi
criteria:

--


(Asif) #3

thanks; but, I have must clause in the same boolean query. I will try
should clause and see how it goes.

On Wednesday, September 5, 2012 8:46:20 PM UTC+5, P Hill wrote:

Look at a should clause, that is the equivalent of "OR".
http://www.elasticsearch.org/guide/reference/query-dsl/bool-query.html
"A boolean query with no |must| clauses, one or more |should| clauses
must match a document. "

-Paul

On 9/5/2012 7:34 AM, Asif wrote:

Hi,
I want to search documents that match either of two following twi
criteria:

--


(phill) #4

Since you only posted twice in this thread and you changed your criteria
between them, I suggest you post the entire problem. I'm sure there is
a combination of clauses and nested queries that will get the job done.

-Paul

On 9/6/2012 5:00 AM, Asif wrote:

thanks; but, I have must clause in the same boolean query. I will
try should clause and see how it goes.

--


(system) #5