Term Scripts in terms facet

Hi,

Lets assume that test_facet is an array with two fields: field_name and
field_value. The following request:
{
"facets":{
"test_facet":{
"terms":{
"field":"test_array.field_name",
}
}
}
}

will return facet grouping by field_name.

Now I want to get grouping by field_name + ":" + field_value.
Using something like this:
{
"facets":{
"test_facet":{
"terms":{
"field":"test_array.field_name",
"script":"term + ":" + field_value"
}
}
}
}

unfortunatelly does not work.

Do you know if it is possible to get such grouping? If it is possible then
how ? :slight_smile:

Thanks
Best regards
Marcin

You want to access field_value from the doc? In this case, you need to do
doc.field_value.value. But note, if both are multi valued, then there won't
be any ordering guaranteed between them (the field_name and field_value).

On Thu, Apr 12, 2012 at 5:30 PM, Marcin Dojwa m.dojwa@livechatinc.comwrote:

Hi,

Lets assume that test_facet is an array with two fields: field_name and
field_value. The following request:
{
"facets":{
"test_facet":{
"terms":{
"field":"test_array.field_name",
}
}
}
}

will return facet grouping by field_name.

Now I want to get grouping by field_name + ":" + field_value.
Using something like this:
{
"facets":{
"test_facet":{
"terms":{
"field":"test_array.field_name",
"script":"term + ":" + field_value"
}
}
}
}

unfortunatelly does not work.

Do you know if it is possible to get such grouping? If it is possible then
how ? :slight_smile:

Thanks
Best regards
Marcin

Thank you Shay, I found the answer using complicated scripts (not so
efficient) in other posts. I guess the best way here is to reorganize
document structure to do it other way :slight_smile:

Thanks again.
Best regards.

2012/4/13 Shay Banon kimchy@gmail.com

You want to access field_value from the doc? In this case, you need to do
doc.field_value.value. But note, if both are multi valued, then there won't
be any ordering guaranteed between them (the field_name and field_value).

On Thu, Apr 12, 2012 at 5:30 PM, Marcin Dojwa m.dojwa@livechatinc.comwrote:

Hi,

Lets assume that test_facet is an array with two fields: field_name and
field_value. The following request:
{
"facets":{
"test_facet":{
"terms":{
"field":"test_array.field_name",
}
}
}
}

will return facet grouping by field_name.

Now I want to get grouping by field_name + ":" + field_value.
Using something like this:
{
"facets":{
"test_facet":{
"terms":{
"field":"test_array.field_name",
"script":"term + ":" + field_value"
}
}
}
}

unfortunatelly does not work.

Do you know if it is possible to get such grouping? If it is possible
then how ? :slight_smile:

Thanks
Best regards
Marcin