Dynamic Rate Calculation

Hi

I'm very new to elasticsearch and was trying to find an efficient way to
solve the following problem.

Lets say I have the following data structure-

{
"name": "Hotel Radisson",
"rates": [
{
"from": "2014-01-01",
"to": "2014-02-02",
"price": 100
},
{
"from": "2014-01-01",
"to": "2014-02-02",
"price": 150
},
...
]
}

Now, I want to do a range query on the rates and calculate a rate using the
resulted data from the result. And, use that rate as facet.

I was thinking of trying with aggregation. But, is it the correct way to do
it? will it be efficient? Or there's a better way to do it.

Thanks in advance.

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/757704a4-28e9-4d3a-8bbe-61197c936907%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Anyone? :frowning:

On Sunday, September 21, 2014 9:17:26 PM UTC+6, Rifat Nabi wrote:

Hi

I'm very new to elasticsearch and was trying to find an efficient way to
solve the following problem.

Lets say I have the following data structure-

{
"name": "Hotel Radisson",
"rates": [
{
"from": "2014-01-01",
"to": "2014-02-02",
"price": 100
},
{
"from": "2014-01-01",
"to": "2014-02-02",
"price": 150
},
...
]
}

Now, I want to do a range query on the rates and calculate a rate using
the resulted data from the result. And, use that rate as facet.

I was thinking of trying with aggregation. But, is it the correct way to
do it? will it be efficient? Or there's a better way to do it.

Thanks in advance.

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/3b6452c6-724c-4612-b6d0-a5f607274dac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

I did not understand what you are trying to produce.

May be you could paste here what kind of output you are expecting?

--
David Pilato | Technical Advocate | elasticsearch.com
david.pilato@elasticsearch.com
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 24 septembre 2014 à 09:19:26, Rifat Nabi (torifat@gmail.com) a écrit:

Anyone? :frowning:

On Sunday, September 21, 2014 9:17:26 PM UTC+6, Rifat Nabi wrote:
Hi

I'm very new to elasticsearch and was trying to find an efficient way to solve the following problem.

Lets say I have the following data structure-

{
"name": "Hotel Radisson",
"rates": [
{
"from": "2014-01-01",
"to": "2014-02-02",
"price": 100
},
{
"from": "2014-01-01",
"to": "2014-02-02",
"price": 150
},
...
]
}

Now, I want to do a range query on the rates and calculate a rate using the resulted data from the result. And, use that rate as facet.

I was thinking of trying with aggregation. But, is it the correct way to do it? will it be efficient? Or there's a better way to do it.

Thanks in advance.

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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/3b6452c6-724c-4612-b6d0-a5f607274dac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/etPan.54227345.216231b.3194%40MacBook-Air-de-David.local.
For more options, visit https://groups.google.com/d/optout.

Sorry that I couldn't explain properly. Let me try again.

So, when I search with the term "Radisson" and a date range. I want to
filter the name with that term and then filter the rates with the date
range. After that do some calculation with those filtered rates. Which will
produce something like the following.

[
{
"name": "Hotel Radisson"
"rate": 80
}
]

On Wednesday, September 24, 2014 1:31:37 PM UTC+6, David Pilato wrote:

I did not understand what you are trying to produce.

May be you could paste here what kind of output you are expecting?

--
David Pilato | Technical Advocate | elasticsearch.com
http://elasticsearch.com

david....@elasticsearch.com <javascript:>
@dadoonet https://twitter.com/dadoonet | @elasticsearchfr
https://twitter.com/elasticsearchfr | @scrutmydocs
http://twitter.com/scrutmydocs
https://twitter.com/scrutmydocs

Le 24 septembre 2014 à 09:19:26, Rifat Nabi (tor...@gmail.com
<javascript:>) a écrit:

Anyone? :frowning:

On Sunday, September 21, 2014 9:17:26 PM UTC+6, Rifat Nabi wrote:

Hi

I'm very new to elasticsearch and was trying to find an efficient way to
solve the following problem.

Lets say I have the following data structure-

{
"name": "Hotel Radisson",
"rates": [
{
"from": "2014-01-01",
"to": "2014-02-02",
"price": 100
},
{
"from": "2014-01-01",
"to": "2014-02-02",
"price": 150
},
...
]
}

Now, I want to do a range query on the rates and calculate a rate using
the resulted data from the result. And, use that rate as facet.

I was thinking of trying with aggregation. But, is it the correct way to
do it? will it be efficient? Or there's a better way to do it.

Thanks in advance.

--
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 <javascript:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/3b6452c6-724c-4612-b6d0-a5f607274dac%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/3b6452c6-724c-4612-b6d0-a5f607274dac%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/62d14c1a-c0db-404c-85a3-d9794e028b9a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

So a match Query and a Range filter?

I'm not sure I understand. May be you could try to GIST a script and show what you have tried so far?

As you are starting with elasticsearch, I don't want to over complicate things, but you will probably need at some point to use nested documents.

At this moment, I'd suggest to index documents per rate. So:

PUT index/type/1
{
"name": "Hotel Radisson",
"rates": {
"from": "2014-01-01",
"to": "2014-02-02",
"price": 100
}
}

PUT index/type/2
{
"name": "Hotel Radisson",
"rates": {
"from": "2014-01-01",
"to": "2014-02-02",
"price": 150
}
}

--
David Pilato | Technical Advocate | elasticsearch.com
david.pilato@elasticsearch.com
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 24 septembre 2014 à 09:39:06, Rifat Nabi (torifat@gmail.com) a écrit:

Sorry that I couldn't explain properly. Let me try again.

So, when I search with the term "Radisson" and a date range. I want to filter the name with that term and then filter the rates with the date range. After that do some calculation with those filtered rates. Which will produce something like the following.

[
{
"name": "Hotel Radisson"
"rate": 80
}
]

On Wednesday, September 24, 2014 1:31:37 PM UTC+6, David Pilato wrote:
I did not understand what you are trying to produce.

May be you could paste here what kind of output you are expecting?

--
David Pilato | Technical Advocate | elasticsearch.com
david....@elasticsearch.com
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 24 septembre 2014 à 09:19:26, Rifat Nabi (tor...@gmail.com) a écrit:

Anyone? :frowning:

On Sunday, September 21, 2014 9:17:26 PM UTC+6, Rifat Nabi wrote:
Hi

I'm very new to elasticsearch and was trying to find an efficient way to solve the following problem.

Lets say I have the following data structure-

{
"name": "Hotel Radisson",
"rates": [
{
"from": "2014-01-01",
"to": "2014-02-02",
"price": 100
},
{
"from": "2014-01-01",
"to": "2014-02-02",
"price": 150
},
...
]
}

Now, I want to do a range query on the rates and calculate a rate using the resulted data from the result. And, use that rate as facet.

I was thinking of trying with aggregation. But, is it the correct way to do it? will it be efficient? Or there's a better way to do it.

Thanks in advance.

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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/3b6452c6-724c-4612-b6d0-a5f607274dac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/62d14c1a-c0db-404c-85a3-d9794e028b9a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/etPan.54227670.66ef438d.3194%40MacBook-Air-de-David.local.
For more options, visit https://groups.google.com/d/optout.