How do I create this query? Q = date > X and ("term" in body OR "term" in title)

I believe you could have also done the same thing with a query the was
PRE filtered which is what search request with a query and a filter
would give you.
{ "query": { ... }, "filter " : { ...} }
I don't believe the order of query and filter matters in the above. The
hits are NO different than filtered query in your case (because your two
clauses "and" together regardless of order). The
only difference is when calculating "facets", a facets would NOT see
the results of a query-level filter, while the filtered query (filter
inside the query) will effect any facets.

[Before adding a query level filter, "[w]e get two hits, and the
relevant facets with a count of 1 for both |green| and |blue [...|] add
a filter [...] And now, we get only 1 hit back, but the facets remain
the same."

So if you're not using facets you were on the right track initially.

-Paul

On 8/29/2012 9:27 AM, D wrote:

Filtered query does it as well, in fact it's what I had in mind:

{"query": {
"filtered": {
"query": {"query_string": {"fields": ["title", "body"], "query": "term"}},
"filter": {"range": {"created": {"gt": "2012-01-01T12:00:00"}}}
}
}}

On Wednesday, August 29, 2012 5:02:18 PM UTC+2, D wrote:

Hi,

I'm new to Elasticsearch and a bit confusted the Query DSL. I have
a mapping for a type like this {created: date, title: string,
body: string}
How do I search for all documents created after a certain date
that contain a certain string in either the body or the title.

So something like Q = date > X and ("term" in body OR "term" in title)

{
  'filter': {'range': {'created': {'gt': "2012-01-01T12:00:00"}}},
  '...' # This is where I'm confused
}

--

--