Facets : get all nested fields, without specifiyng the name

Hi !

I am currently playing with facets, and I am facing the following problems.
The documents I am indexing are products. They have different fields
(Title, id) and a list of attributes, defined in a nested field.

My mapping looks like this :

mappings: {
product: {
properties: {
title: {
type: string
}
id: {
type: long
}
attributes: {
dynamic: true
properties: {
screen: {
type: string
}
color: {
type: string
}
brand: {
type: string
}
type: {
type: string
}
memory: {
type: string
}
}
}
}
}
}

What I want to do, is to get a count of the different values I have within
"attributes". I can easily do it by specyfing the name of theses fields in
the facets by doing something like this :

{
"query" : {
"match_all" : {}
},
"facets" : {
"tags" : { "terms" : {"fields" : ["brand", "color"]} }
}
}

But what i would actually like to do is a bit different. As I may not know
the fields within the "attributes" part, i would like to build my facets by
doing something like "Give me a count for all the fields within the
attribute field".
Is this somehow possible ?

Thanks in advance

Sebastian

--
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.

I would probably ask ES for mapping of your type. Then build one Terms facet per field in attributes object.

So you should probably handle that on client side.

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

Le 14 juin 2013 à 11:07, Sebastianpx sebastian.piedoux@gmail.com a écrit :

Hi !

I am currently playing with facets, and I am facing the following problems.
The documents I am indexing are products. They have different fields (Title, id) and a list of attributes, defined in a nested field.

My mapping looks like this :

mappings: {
product: {
properties: {
title: {
type: string
}
id: {
type: long
}
attributes: {
dynamic: true
properties: {
screen: {
type: string
}
color: {
type: string
}
brand: {
type: string
}
type: {
type: string
}
memory: {
type: string
}
}
}
}
}
}

What I want to do, is to get a count of the different values I have within "attributes". I can easily do it by specyfing the name of theses fields in the facets by doing something like this :

{
"query" : {
"match_all" : {}
},
"facets" : {
"tags" : { "terms" : {"fields" : ["brand", "color"]} }
}
}

But what i would actually like to do is a bit different. As I may not know the fields within the "attributes" part, i would like to build my facets by doing something like "Give me a count for all the fields within the attribute field".
Is this somehow possible ?

Thanks in advance

Sebastian

--
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 for you answer, we decided to follow a similar approach !