Function_score iterate through nested objects

Hi,

i have products in my index and i would like to sort them by the lowest
price of a client. I think i have to use a function_score for that?

//Product Mapping
{
ArticleNumber: 1000,
Title: "sample product",
Clients: [
{
Type: "K",
Price: 10,
ClientIds: [
1,
2
]
},
{
Type: "K",
Price: 9,
ClientIds: [
3
]
}
],
}

Currently my query looks like this. But i don't know how i can iterate over
the nested "Clients" Objects and get the lowest price for the Client with
the Id 1.

query: {
function_score: {
boost_mode: "replace",
query: {
match_all: { }
},
functions: [
{
script_score: {
script: "miss script to iterate over the Clients",
lang: "groovy"
}
}
]
}
}

Any help would be appreciated.

--
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/8f42c4e6-7706-4d8d-9105-ac1fda1ed43c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hello Kisi ,

You can use score_mode as min on that field -

But i guess for that to work , you need to enable
"include_in_parent": true,

In nested type -

Thanks
Vineeth

On Sat, Aug 23, 2014 at 4:27 PM, kisi koglchri@gmail.com wrote:

Hi,

i have products in my index and i would like to sort them by the lowest
price of a client. I think i have to use a function_score for that?

//Product Mapping
{
ArticleNumber: 1000,
Title: "sample product",
Clients: [
{
Type: "K",
Price: 10,
ClientIds: [
1,
2
]
},
{
Type: "K",
Price: 9,
ClientIds: [
3
]
}
],
}

Currently my query looks like this. But i don't know how i can iterate
over the nested "Clients" Objects and get the lowest price for the Client
with the Id 1.

query: {
function_score: {
boost_mode: "replace",
query: {
match_all: { }
},
functions: [
{
script_score: {
script: "miss script to iterate over the Clients",
lang: "groovy"
}
}
]
}
}

Any help would be appreciated.

--
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/8f42c4e6-7706-4d8d-9105-ac1fda1ed43c%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/8f42c4e6-7706-4d8d-9105-ac1fda1ed43c%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/CAGdPd5mZgEt3tJBxQLkJK_5tp_tp6vHZhQWY9WbbgY0FZFWvvA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.