Deviland
Deviland

Reputation: 3374

Query within date range for specific data

I have an index of events like so (please excuse the simplified free hand version)

{event:{ properties: {id:{type: 'string'}, start:{type: 'date'}}}

I want to query this data to return all events within a week from now, with an additional weekend filter. I accomplish the first part of the query with the following.

{
"query": {
"range": {
  "start": {
    "from": "2014-02-25 09:14:09 UTC",
    "to": "2014-03-04 09:14:09 UTC"
   }
  }
 }
}

but I have a problem I want to query the week as above, but I only need five of the days from the result set, if a weekend falls within the five days and has an event then return that event f not return a further day so in essence

with no weekend event should look like this

wed, thurs, fri, mon, tues

with weekendd event should look like this

wed, thurs, fri, sat, mon

Upvotes: 0

Views: 78

Answers (1)

Deviland
Deviland

Reputation: 3374

I have changed the requirement instead, I ma not totally sure this is possible in elastic search, so I have took the seven days and used code to filter the results

Upvotes: 1

Related Questions