Date Interval Pattern

Hello,
I'm new to elastic search and I'm having a good time doing some
benchmarking. However, It's not clear to me what the ideal pattern would be
for storing and querying date intervals. Most of the example date code
involves storing an instant and querying with a date range. I would like to
invert that.

Ideally I would store an array of date intervals like:

  1. 2012-12-01T00:00:00 - 2012-12-10T00:00:00
  2. 2012-12-12T00:00:00 - 2012-12-15T00:00:00

On a single object and then query for when an interval is contained in or
overlaps with any of the stored date intervals.

I can see how I could create an index of an interval object with start and
end mappings and make an array of those but querying would be a VERY
verbose set of criteria.

Does anyone have any recommendations or is that the best I'm going to do?

Thanks,
Gus

--

Hi,

I think you might want to look at nested type (and nested filter or nested
query as well).

Regards,
Lukas

On Fri, Dec 14, 2012 at 9:48 PM, Gus Holcomb gus@relayrides.com wrote:

Hello,
I'm new to elastic search and I'm having a good time doing some
benchmarking. However, It's not clear to me what the ideal pattern would be
for storing and querying date intervals. Most of the example date code
involves storing an instant and querying with a date range. I would like to
invert that.

Ideally I would store an array of date intervals like:

  1. 2012-12-01T00:00:00 - 2012-12-10T00:00:00
  2. 2012-12-12T00:00:00 - 2012-12-15T00:00:00

On a single object and then query for when an interval is contained in or
overlaps with any of the stored date intervals.

I can see how I could create an index of an interval object with start and
end mappings and make an array of those but querying would be a VERY
verbose set of criteria.

Does anyone have any recommendations or is that the best I'm going to do?

Thanks,
Gus

--

--