# Elasticsearch sequential dates

**URL:** https://discuss.elastic.co/t/elasticsearch-sequential-dates/15612
**Category:** Elasticsearch
**Created:** [February 5, 2014, 9:33am UTC](https://discuss.elastic.co/t/elasticsearch-sequential-dates/15612 "2014-02-05T09:33:35Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Simon\_Leighton](https://avatars.discourse-cdn.com/v4/letter/s/dfb087/32.png) [@Simon\_Leighton](https://discuss.elastic.co/u/Simon_Leighton)
#### Post date: [February 5, 2014, 9:33am UTC](https://discuss.elastic.co/t/elasticsearch-sequential-dates/15612/1 "2014-02-05T09:33:35Z")

</div>

I Asked this on stack overflow but I see searching around for some pointers  
most questions are being directed back to the ES mailing lists so here I  
go...

I am creating a hotel booking system using Elasticsearch and am trying to  
find a way to return hotels that have a variable number of sequential dates  
available (for example 7 days) across a range of dates

I am currently storing dates and prices as a child document to the hotel  
but am unsure how to undertake the search or if it is even possible with my  
current setup?

Thanks

Simon

--  
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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/ac5e1690-1c4c-4971-a35b-02237cf0add5%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/ac5e1690-1c4c-4971-a35b-02237cf0add5%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [February 5, 2014, 10:00am UTC](https://discuss.elastic.co/t/elasticsearch-sequential-dates/15612/2 "2014-02-05T10:00:48Z")

</div>

Wondering if you should not index availability instead of indexing rooms. (I don't know how your documents look like BTW)

Let's say you create documents like

{  
"hotel":"name",  
"room":"A205",  
"available": [ {  
"from": "2014-02-13",  
"to": "2014-02-14",  
"days":2  
}, {  
"from": "2014-02-16",  
"to": "2014-02-20",  
"days":5  
} ]  
}

Could this help?  
That say, I think you can compute `days` when running the query but it well be easier and probably more efficient to compute it at index time (so on client level).

WDYT?

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr

Le 5 février 2014 at 10:33:38, Simon Leighton ([simonwleighton@gmail.com](mailto:simonwleighton@gmail.com)) a écrit:

I Asked this on stack overflow but I see searching around for some pointers most questions are being directed back to the ES mailing lists so here I go...

I am creating a hotel booking system using Elasticsearch and am trying to find a way to return hotels that have a variable number of sequential dates available (for example 7 days) across a range of dates

I am currently storing dates and prices as a child document to the hotel but am unsure how to undertake the search or if it is even possible with my current setup?

Thanks

Simon

--  
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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/ac5e1690-1c4c-4971-a35b-02237cf0add5%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/ac5e1690-1c4c-4971-a35b-02237cf0add5%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/etPan.52f20bd0.189a769b.d955%40MacBook-Air-de-David.local](https://groups.google.com/d/msgid/elasticsearch/etPan.52f20bd0.189a769b.d955%40MacBook-Air-de-David.local).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Simon\_Leighton](https://avatars.discourse-cdn.com/v4/letter/s/dfb087/32.png) [@Simon\_Leighton](https://discuss.elastic.co/u/Simon_Leighton)
#### Post date: [February 5, 2014, 10:19am UTC](https://discuss.elastic.co/t/elasticsearch-sequential-dates/15612/3 "2014-02-05T10:19:05Z")

</div>

Hi David,

I'm pulling in the room availability for an API so I'll only get  
availability one date at a time hence why I'm thinking of using child  
documents as to not need to constantly update the hotel data in the parent.  
Each day has an individual price so I'm trying to find the cheapest block  
of say 7 days (this is user specified so could be anywhere from 1 - 14).

Thanks  
Simon

On Wednesday, 5 February 2014 10:00:48 UTC, David Pilato wrote:

> Wondering if you should not index availability instead of indexing rooms.  
> (I don't know how your documents look like BTW)
> 
> Let's say you create documents like
> 
> {  
> "hotel":"name",  
> "room":"A205",  
> "available": [ {  
> "from": "2014-02-13",  
> "to": "2014-02-14",  
> "days":2  
> }, {  
> "from": "2014-02-16",  
> "to": "2014-02-20",  
> "days":5  
> } ]  
> }
> 
> Could this help?  
> That say, I think you can compute `days` when running the query but it  
> well be easier and probably more efficient to compute it at index time (so  
> on client level).
> 
> WDYT?
> 
> --  
> _David Pilato_ | _Technical Advocate_ | _[Elasticsearch.com](http://Elasticsearch.com)_  
> @dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr[https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr)
> 
> Le 5 février 2014 at 10:33:38, Simon Leighton ([simonwl...@gmail.com](mailto:simonwl...@gmail.com)\<javascript:\>)  
> a écrit:
> 
> I Asked this on stack overflow but I see searching around for some  
> pointers most questions are being directed back to the ES mailing lists so  
> here I go...
> 
> I am creating a hotel booking system using Elasticsearch and am trying to  
> find a way to return hotels that have a variable number of sequential dates  
> available (for example 7 days) across a range of dates
> 
> I am currently storing dates and prices as a child document to the hotel  
> but am unsure how to undertake the search or if it is even possible with my  
> current setup?
> 
> Thanks
> 
> ## Simon
> 
> 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/ac5e1690-1c4c-4971-a35b-02237cf0add5%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/ac5e1690-1c4c-4971-a35b-02237cf0add5%40googlegroups.com)  
> .  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/b5bead0e-4118-41cf-b18e-eaca181d78bf%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b5bead0e-4118-41cf-b18e-eaca181d78bf%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)
#### Post date: [February 5, 2014, 10:49am UTC](https://discuss.elastic.co/t/elasticsearch-sequential-dates/15612/4 "2014-02-05T10:49:41Z")

</div>

If you want to find the cheapest block, you should also index the 14 prices  
for the availabilities.

Jörg

On Wed, Feb 5, 2014 at 11:19 AM, Simon Leighton [simonwleighton@gmail.com](mailto:simonwleighton@gmail.com)wrote:

> Hi David,
> 
> I'm pulling in the room availability for an API so I'll only get  
> availability one date at a time hence why I'm thinking of using child  
> documents as to not need to constantly update the hotel data in the parent.  
> Each day has an individual price so I'm trying to find the cheapest block  
> of say 7 days (this is user specified so could be anywhere from 1 - 14).

--  
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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGSubmyArBbWsDd51Kc4P%2BQFV5g-p%2Bsy6Nx6J-\_BoookA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGSubmyArBbWsDd51Kc4P%2BQFV5g-p%2Bsy6Nx6J-_BoookA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 6, 2017, 1:52am UTC](https://discuss.elastic.co/t/elasticsearch-sequential-dates/15612/5 "2017-07-06T01:52:28Z")

</div>


