How to iterate through array of objects

HI All,

I have index with mapping:
"properties":{ "Availability":{"dynamic":"true","properties":{"Period":{
"type":"string"},"Price":{"type":"double"}}} }

I want to iterate through array of objects
how can I do it in ES script using MVEL language?

What's important I particularly* want to access Period and Price for the
same (*concurrent) index/id/object (don't known what is proper term in
ES). *
For every Period there is assigned Price, so for example I want to access *
Availability[j].Period
and Availability[j].Price (for the same
j=0,1,2,3,... and so on).

Thanks in advance and Best for All,
Gzom

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Hey,

The MVEL functions you are searching for is doc['yourField'].values and a
for loop in MVEL. Use it like this:

for (i : doc['a'].values) { do_what_you_want_here }

see http://mvel.codehaus.org/MVEL+2.0+Control+Flow
and Elasticsearch Platform — Find real-time answers at scale | Elastic

--Alex

On Thu, May 9, 2013 at 2:09 PM, waldemar@pureholidayhomes.com wrote:

HI All,

I have index with mapping:
"properties":{ "Availability":{"dynamic":"true","properties":{"Period":{
"type":"string"},"Price":{"type":"double"}}} }

I want to iterate through array of objects
how can I do it in ES script using MVEL language?

What's important I particularly* want to access Period and Price for
the same (**concurrent) index/id/object (don't known what is proper term
in ES). *
For every Period there is assigned Price, so for example I want to access
Availability[j].Period and Availability[j].Price (for the same
j=0,1,2,3,... and so on).

Thanks in advance and Best for All,
Gzom

--
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.
For more options, visit 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.
For more options, visit https://groups.google.com/groups/opt_out.

Thank you Alexander for your suggestion, but it is not working :frowning:

I have used script:
"script":"for(element : doc["Availability"].values){return element.Period
+"="+ element.Price}"

And I get error:
ElasticSearchIllegalArgumentException[No field found for
[AvailabilityPeriodV2] in mapping

Any other suggestions?

Thanks,
Gzom

On Friday, 10 May 2013 10:06:13 UTC+2, Alexander Reelsen wrote:

Hey,

The MVEL functions you are searching for is doc['yourField'].values and a
for loop in MVEL. Use it like this:

for (i : doc['a'].values) { do_what_you_want_here }

see http://mvel.codehaus.org/MVEL+2.0+Control+Flow
and Elasticsearch Platform — Find real-time answers at scale | Elastic

--Alex

On Thu, May 9, 2013 at 2:09 PM, <wald...@pureholidayhomes.com<javascript:>

wrote:

HI All,

I have index with mapping:
"properties":{ "Availability":{"dynamic":"true","properties":{"Period":{
"type":"string"},"Price":{"type":"double"}}} }

I want to iterate through array of objects
how can I do it in ES script using MVEL language?

What's important I particularly* want to access Period and Price for
the same (**concurrent) index/id/object (don't known what is proper term
in ES). *
For every Period there is assigned Price, so for example I want to access
Availability[j].Period and Availability[j].Price (for the same
j=0,1,2,3,... and so on).

Thanks in advance and Best for All,
Gzom

--
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:>.
For more options, visit 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.
For more options, visit https://groups.google.com/groups/opt_out.

doc["Availability"]

Should be

doc["Availability"]

My 2 cents

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 10 mai 2013 à 11:38, waldemar@pureholidayhomes.com a écrit :

Thank you Alexander for your suggestion, but it is not working :frowning:

I have used script:
"script":"for(element : doc["Availability"].values){return element.Period +"="+ element.Price}"

And I get error:
ElasticSearchIllegalArgumentException[No field found for [AvailabilityPeriodV2] in mapping

Any other suggestions?

Thanks,
Gzom

On Friday, 10 May 2013 10:06:13 UTC+2, Alexander Reelsen wrote:

Hey,

The MVEL functions you are searching for is doc['yourField'].values and a for loop in MVEL. Use it like this:

for (i : doc['a'].values) { do_what_you_want_here }

see http://mvel.codehaus.org/MVEL+2.0+Control+Flow
and Elasticsearch Platform — Find real-time answers at scale | Elastic

--Alex

On Thu, May 9, 2013 at 2:09 PM, wald...@pureholidayhomes.com wrote:

HI All,

I have index with mapping:
"properties":{ "Availability":{"dynamic":"true","properties":{"Period":{"type":"string"},"Price":{"type":"double"}}} }

I want to iterate through array of objects
how can I do it in ES script using MVEL language?

What's important I particularly want to access Period and Price for the same (concurrent) index/id/object (don't known what is proper term in ES).
For every Period there is assigned Price, so for example I want to access Availability[j].Period and Availability[j].Price (for the same j=0,1,2,3,... and so on).

Thanks in advance and Best for All,
Gzom

--
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.
For more options, visit 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.
For more options, visit 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.
For more options, visit https://groups.google.com/groups/opt_out.

Yes, that is misspeling for the copy paste.

I have used script:
"script":"for(element : doc["Availability"].values){return element.Period
+"="+ element.Price}"

And I get error:
ElasticSearchIllegalArgumentException[No field found for [Availability] in
mapping

Any other suggestions?

Thanks,
Gzom

On Friday, 10 May 2013 11:45:21 UTC+2, David Pilato wrote:

doc["Availability"]

Should be

doc["Availability"]

My 2 cents

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 10 mai 2013 à 11:38, wald...@pureholidayhomes.com <javascript:> a
écrit :

Thank you Alexander for your suggestion, but it is not working :frowning:

I have used script:
"script":"for(element : doc["Availability"].values){return element.Period
+"="+ element.Price}"

And I get error:
ElasticSearchIllegalArgumentException[No field found for
[AvailabilityPeriodV2] in mapping

Any other suggestions?

Thanks,
Gzom

On Friday, 10 May 2013 10:06:13 UTC+2, Alexander Reelsen wrote:

Hey,

The MVEL functions you are searching for is doc['yourField'].values and a
for loop in MVEL. Use it like this:

for (i : doc['a'].values) { do_what_you_want_here }

see http://mvel.codehaus.org/MVEL+2.0+Control+Flow
and Elasticsearch Platform — Find real-time answers at scale | Elastic

--Alex

On Thu, May 9, 2013 at 2:09 PM, wald...@pureholidayhomes.com wrote:

HI All,

I have index with mapping:
"properties":{ "Availability":{"dynamic":"true","properties":{"Period":{
"type":"string"},"Price":{"type":"double"}}} }

I want to iterate through array of objects
how can I do it in ES script using MVEL language?

What's important I particularly* want to access Period and Price for
the same (**concurrent) index/id/object (don't known what is proper
term in ES). *
For every Period there is assigned Price, so for example I want to
access Availability[j].Period and Availability[j].Price (for the
same j=0,1,2,3,... and so on).

Thanks in advance and Best for All,
Gzom

--
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.
For more options, visit 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 elasticsearc...@googlegroups.com <javascript:>.
For more options, visit 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.
For more options, visit https://groups.google.com/groups/opt_out.

Because Avaibility is not an array but an object with two nested properties.
Can you post a sample doc here?

BTW, I think you should use nested docs for your use case.
Othewise, your properties will be flatten and you won't be able to find a relation between Avaibility and price.

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 10 mai 2013 à 12:19, waldemar@pureholidayhomes.com a écrit :

Yes, that is misspeling for the copy paste.

I have used script:
"script":"for(element : doc["Availability"].values){return element.Period +"="+ element.Price}"

And I get error:
ElasticSearchIllegalArgumentException[No field found for [Availability] in mapping

Any other suggestions?

Thanks,
Gzom

On Friday, 10 May 2013 11:45:21 UTC+2, David Pilato wrote:

doc["Availability"]

Should be

doc["Availability"]

My 2 cents

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 10 mai 2013 à 11:38, wald...@pureholidayhomes.com a écrit :

Thank you Alexander for your suggestion, but it is not working :frowning:

I have used script:
"script":"for(element : doc["Availability"].values){return element.Period +"="+ element.Price}"

And I get error:
ElasticSearchIllegalArgumentException[No field found for [AvailabilityPeriodV2] in mapping

Any other suggestions?

Thanks,
Gzom

On Friday, 10 May 2013 10:06:13 UTC+2, Alexander Reelsen wrote:

Hey,

The MVEL functions you are searching for is doc['yourField'].values and a for loop in MVEL. Use it like this:

for (i : doc['a'].values) { do_what_you_want_here }

see http://mvel.codehaus.org/MVEL+2.0+Control+Flow
and Elasticsearch Platform — Find real-time answers at scale | Elastic

--Alex

On Thu, May 9, 2013 at 2:09 PM, wald...@pureholidayhomes.com wrote:

HI All,

I have index with mapping:
"properties":{ "Availability":{"dynamic":"true","properties":{"Period":{"type":"string"},"Price":{"type":"double"}}} }

I want to iterate through array of objects
how can I do it in ES script using MVEL language?

What's important I particularly want to access Period and Price for the same (concurrent) index/id/object (don't known what is proper term in ES).
For every Period there is assigned Price, so for example I want to access Availability[j].Period and Availability[j].Price (for the same j=0,1,2,3,... and so on).

Thanks in advance and Best for All,
Gzom

--
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.
For more options, visit 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 elasticsearc...@googlegroups.com.
For more options, visit 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.
For more options, visit 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.
For more options, visit https://groups.google.com/groups/opt_out.

Hi David,

My sample doc:

*"Availability":[

{
    "Period":"2013-06-05|2013-05-09",
    "Price": 53.37
},
{
    "Period":"2013-06-07|2013-05-10",
    "Price": 106.75
}

]
*
*And I can't use nested docs for the performance reason. *

Thnaks in advance,
Gzom

On Friday, 10 May 2013 12:27:31 UTC+2, David Pilato wrote:

Because Avaibility is not an array but an object with two nested
properties.
Can you post a sample doc here?

BTW, I think you should use nested docs for your use case.
Othewise, your properties will be flatten and you won't be able to find a
relation between Avaibility and price.

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 10 mai 2013 à 12:19, wald...@pureholidayhomes.com <javascript:> a
écrit :

Yes, that is misspeling for the copy paste.

I have used script:
"script":"for(element : doc["Availability"].values){return element.
Period +"="+ element.Price}"

And I get error:
ElasticSearchIllegalArgumentException[No field found for [Availability]
in mapping

Any other suggestions?

Thanks,
Gzom

On Friday, 10 May 2013 11:45:21 UTC+2, David Pilato wrote:

doc["Availability"]

Should be

doc["Availability"]

My 2 cents

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 10 mai 2013 à 11:38, wald...@pureholidayhomes.com a écrit :

Thank you Alexander for your suggestion, but it is not working :frowning:

I have used script:
"script":"for(element : doc["Availability"].values){return element.
Period +"="+ element.Price}"

And I get error:
ElasticSearchIllegalArgumentException[No field found for
[AvailabilityPeriodV2] in mapping

Any other suggestions?

Thanks,
Gzom

On Friday, 10 May 2013 10:06:13 UTC+2, Alexander Reelsen wrote:

Hey,

The MVEL functions you are searching for is doc['yourField'].values and
a for loop in MVEL. Use it like this:

for (i : doc['a'].values) { do_what_you_want_here }

see http://mvel.codehaus.org/MVEL+2.0+Control+Flow
and Elasticsearch Platform — Find real-time answers at scale | Elastic

--Alex

On Thu, May 9, 2013 at 2:09 PM, wald...@pureholidayhomes.com wrote:

HI All,

I have index with mapping:
"properties":{ "Availability":{"dynamic":"true","properties":{"Period"
:{"type":"string"},"Price":{"type":"double"}}} }

I want to iterate through array of objects
how can I do it in ES script using MVEL language?

What's important I particularly* want to access Period and Price for
the same (**concurrent) index/id/object (don't known what is proper
term in ES). *
For every Period there is assigned Price, so for example I want to
access Availability[j].Period and Availability[j].Price (for the
same j=0,1,2,3,... and so on).

Thanks in advance and Best for All,
Gzom

--
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.
For more options, visit 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 elasticsearc...@googlegroups.com.
For more options, visit 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 elasticsearc...@googlegroups.com <javascript:>.
For more options, visit 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.
For more options, visit https://groups.google.com/groups/opt_out.

Is it possible not to use nested docs and still have array with relation
between Period an Price ?

Thanks,
Gzom

On Friday, 10 May 2013 12:27:31 UTC+2, David Pilato wrote:

Because Avaibility is not an array but an object with two nested
properties.
Can you post a sample doc here?

BTW, I think you should use nested docs for your use case.
Othewise, your properties will be flatten and you won't be able to find a
relation between Avaibility and price.

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 10 mai 2013 à 12:19, wald...@pureholidayhomes.com <javascript:> a
écrit :

Yes, that is misspeling for the copy paste.

I have used script:
"script":"for(element : doc["Availability"].values){return element.
Period +"="+ element.Price}"

And I get error:
ElasticSearchIllegalArgumentException[No field found for [Availability]
in mapping

Any other suggestions?

Thanks,
Gzom

On Friday, 10 May 2013 11:45:21 UTC+2, David Pilato wrote:

doc["Availability"]

Should be

doc["Availability"]

My 2 cents

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 10 mai 2013 à 11:38, wald...@pureholidayhomes.com a écrit :

Thank you Alexander for your suggestion, but it is not working :frowning:

I have used script:
"script":"for(element : doc["Availability"].values){return element.
Period +"="+ element.Price}"

And I get error:
ElasticSearchIllegalArgumentException[No field found for
[AvailabilityPeriodV2] in mapping

Any other suggestions?

Thanks,
Gzom

On Friday, 10 May 2013 10:06:13 UTC+2, Alexander Reelsen wrote:

Hey,

The MVEL functions you are searching for is doc['yourField'].values and
a for loop in MVEL. Use it like this:

for (i : doc['a'].values) { do_what_you_want_here }

see http://mvel.codehaus.org/MVEL+2.0+Control+Flow
and Elasticsearch Platform — Find real-time answers at scale | Elastic

--Alex

On Thu, May 9, 2013 at 2:09 PM, wald...@pureholidayhomes.com wrote:

HI All,

I have index with mapping:
"properties":{ "Availability":{"dynamic":"true","properties":{"Period"
:{"type":"string"},"Price":{"type":"double"}}} }

I want to iterate through array of objects
how can I do it in ES script using MVEL language?

What's important I particularly* want to access Period and Price for
the same (**concurrent) index/id/object (don't known what is proper
term in ES). *
For every Period there is assigned Price, so for example I want to
access Availability[j].Period and Availability[j].Price (for the
same j=0,1,2,3,... and so on).

Thanks in advance and Best for All,
Gzom

--
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.
For more options, visit 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 elasticsearc...@googlegroups.com.
For more options, visit 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 elasticsearc...@googlegroups.com <javascript:>.
For more options, visit 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.
For more options, visit https://groups.google.com/groups/opt_out.

Hi Gzom,

Just a thought.... it's worked well for me in a past life when creating
arrays of [ lat, lon ] pairs but the database only supported multivalued
fields of basic types but not complex types.

Perhaps:

"Availability_Period" : [ "2013-06-05|2013-05-09", "2013-06-05|2013-05-09" ]

"Availability_Price" : [ 53.37, 106.75 ]

The two arrays are related by position. For example, Availability_Period[n
] corresponds to Availability_Price[n].

Might this help? Just a thought...

Regards,
Brian

On Friday, May 10, 2013 6:39:22 AM UTC-4, wald...@pureholidayhomes.com
wrote:

Hi David,

My sample doc:

*"Availability":[

{
    "Period":"2013-06-05|2013-05-09",
    "Price": 53.37
},
{
    "Period":"2013-06-07|2013-05-10",
    "Price": 106.75
}

]
*
*And I can't use nested docs for the performance reason. *

Thnaks in advance,
Gzom

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Thanks Brian for your idea, I will check that in next few day (now too many
responsibilities), and come back with results .
Best,
Gzom

On Friday, 10 May 2013 18:59:36 UTC+2, InquiringMind wrote:

Hi Gzom,

Just a thought.... it's worked well for me in a past life when creating
arrays of [ lat, lon ] pairs but the database only supported multivalued
fields of basic types but not complex types.

Perhaps:

"Availability_Period" : [ "2013-06-05|2013-05-09", "2013-06-05|2013-05-09"
]

"Availability_Price" : [ 53.37, 106.75 ]

The two arrays are related by position. For example, Availability_Period[*
n*] corresponds to Availability_Price[n].

Might this help? Just a thought...

Regards,
Brian

On Friday, May 10, 2013 6:39:22 AM UTC-4, wald...@pureholidayhomes.comwrote:

Hi David,

My sample doc:

*"Availability":[

{
    "Period":"2013-06-05|2013-05-09",
    "Price": 53.37
},
{
    "Period":"2013-06-07|2013-05-10",
    "Price": 106.75
}

]
*
*And I can't use nested docs for the performance reason. *

Thnaks in advance,
Gzom

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Hi Brian,

Could you provide some code example?
Because I have tested everything what's on internet, and without success.
Maybe I'm doing something wrong?

Best,
Gzom

PS. Thanks for your idea, I will check that in next few day (now too
many responsibilities), and come back with results .

W dniu 2013-05-10 18:59, InquiringMind pisze:

Hi Gzom,

Just a thought.... it's worked well for me in a past life when
creating arrays of [ lat, lon ] pairs but the database only supported
multivalued fields of basic types but not complex types.

Perhaps:

"Availability_Period" : [ "2013-06-05|2013-05-09",
"2013-06-05|2013-05-09" ]

"Availability_Price" : [ 53.37, 106.75 ]

The two arrays are related by position. For example,
Availability_Period[/n/] corresponds to Availability_Price[/n/].

Might this help? Just a thought...

Regards,
Brian

On Friday, May 10, 2013 6:39:22 AM UTC-4, wald...@pureholidayhomes.com
wrote:

Hi David,

My sample doc:

/"Availability":[

    {
        "Period":"2013-06-05|2013-05-09",
        "Price": 53.37
    },
    {
        "Period":"2013-06-07|2013-05-10",
        "Price": 106.75
    }
]
/
_And I can't use nested docs for the performance reason. _

Thnaks in advance,
Gzom

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/8Z2KwuPlyas/unsubscribe?hl=en-US.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.
For more options, visit 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.
For more options, visit https://groups.google.com/groups/opt_out.

Hi Gzom,

My suggestion is pretty much language-independent. My previous experience
was based on a C++ database engine I wrote (Elasticsearch blows it away in
the area of updates and smooth cluster replication; I blew away Lucene in
the areas of performance, phrases with wildcards, tock-solid bug-free geo
shapes, and hierarchy support. I would love to marry Elasticsearch with my
non-Lucene indexing magic, but that's a discussion for another day!) and
that C++ code is no longer available to me (but the ideas are!).

But the code (in whatever language you wish) should be pretty simple. The
important concept is that your documents contain two multi-valued fields,
and that the relationship between the values in each of those fields is
handled by your application (load, and query) and not internal to
Elasticsearch. For some index N, the value of field1[N] corresponds to the
value of field2[N].

In my previous experience, I had one lat and lon pair for each document,
but across the hierarchy there could be many, many documents that matched
the query. So I collected the lat and lon values from the related documents
for a hierarchy. I was left with two arrays of the same size (lat and
lon). I would apply each pair of lat[N], lon[N] to the geo index and geo
filter (either circle or generic polygon) and if any of the pairs was
within the range the documents from that hierarchy were kept (in general,
of course). And as I was determining the inclusion, I also updated the
document (in the response, not on disk) with the calculated distance; this
enabled a sort by (smallest) distance and also enabled the client to
highlight the smallest distance so it was easy to see which distance caused
the sorting placement of the hierarchy's returned documents.

Regards,
Brian

On Monday, May 13, 2013 3:37:25 AM UTC-4, Waldemar Ch. wrote:

Hi Brian,

Could you provide some code example?
Because I have tested everything what's on internet, and without success.
Maybe I'm doing something wrong?

Best,
Gzom

PS. Thanks for your idea, I will check that in next few day (now too many
responsibilities), and come back with results .

W dniu 2013-05-10 18:59, InquiringMind pisze:

Hi Gzom,

Just a thought.... it's worked well for me in a past life when creating
arrays of [ lat, lon ] pairs but the database only supported multivalued
fields of basic types but not complex types.

Perhaps:

"Availability_Period" : [ "2013-06-05|2013-05-09",
"2013-06-05|2013-05-09" ]

"Availability_Price" : [ 53.37, 106.75 ]

The two arrays are related by position. For example, Availability_Period[
n] corresponds to Availability_Price[n].

Might this help? Just a thought...

Regards,
Brian

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Hi to All,

For now my solution to this problem is to add (force) counter to the data
field name.
For example, my sample doc is:
"Availability":{

0: {
    Period: 2013-06-15|2013-06-22
    Price: 931
}
1: {
    Period: 2013-09-07|2013-09-14
    Price: 931
}

And then I can iterate through data and associate Period with Price.
So my script will look something like this:
"script_fields":{
"test1":{
"script":"i=0; return
doc["AvailabilityPeriodV2."+i+".Period"].value+"="+doc["AvailabilityPeriodV2."+i+".Price"].value"
}
}

I know that this is not the most sophisticated solution, but it works.

If some one have better idea, then please share.

Thanks, and Best to all of you,
Gzom

On Monday, 13 May 2013 18:34:14 UTC+2, InquiringMind wrote:

Hi Gzom,

My suggestion is pretty much language-independent. My previous experience
was based on a C++ database engine I wrote (Elasticsearch blows it away in
the area of updates and smooth cluster replication; I blew away Lucene in
the areas of performance, phrases with wildcards, tock-solid bug-free geo
shapes, and hierarchy support. I would love to marry Elasticsearch with my
non-Lucene indexing magic, but that's a discussion for another day!) and
that C++ code is no longer available to me (but the ideas are!).

But the code (in whatever language you wish) should be pretty simple. The
important concept is that your documents contain two multi-valued fields,
and that the relationship between the values in each of those fields is
handled by your application (load, and query) and not internal to
Elasticsearch. For some index N, the value of field1[N] corresponds to the
value of field2[N].

In my previous experience, I had one lat and lon pair for each document,
but across the hierarchy there could be many, many documents that matched
the query. So I collected the lat and lon values from the related documents
for a hierarchy. I was left with two arrays of the same size (lat and
lon). I would apply each pair of lat[N], lon[N] to the geo index and geo
filter (either circle or generic polygon) and if any of the pairs was
within the range the documents from that hierarchy were kept (in general,
of course). And as I was determining the inclusion, I also updated the
document (in the response, not on disk) with the calculated distance; this
enabled a sort by (smallest) distance and also enabled the client to
highlight the smallest distance so it was easy to see which distance caused
the sorting placement of the hierarchy's returned documents.

Regards,
Brian

On Monday, May 13, 2013 3:37:25 AM UTC-4, Waldemar Ch. wrote:

Hi Brian,

Could you provide some code example?
Because I have tested everything what's on internet, and without success.
Maybe I'm doing something wrong?

Best,
Gzom

PS. Thanks for your idea, I will check that in next few day (now too many
responsibilities), and come back with results .

W dniu 2013-05-10 18:59, InquiringMind pisze:

Hi Gzom,

Just a thought.... it's worked well for me in a past life when creating
arrays of [ lat, lon ] pairs but the database only supported multivalued
fields of basic types but not complex types.

Perhaps:

"Availability_Period" : [ "2013-06-05|2013-05-09",
"2013-06-05|2013-05-09" ]

"Availability_Price" : [ 53.37, 106.75 ]

The two arrays are related by position. For example,
Availability_Period[n] corresponds to Availability_Price[n].

Might this help? Just a thought...

Regards,
Brian

--
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.
For more options, visit https://groups.google.com/groups/opt_out.