Unable to retrieve all the facet info when using Java API

Hi everyone - I am using Java API client to execute my queries and the
request has facets too. After the query has been executed, I receive an
instance of org.elasticsearch.action.search.SeachResponse.

However I am unable to retrieve all the factet information from this
SearchResponse instance. I tried SearchResponse # getFacets() #
getFacets()and this returns me a Map. The key of this map is the facet
name which is
right and using this I retrieve an instance of
org.elasticsearch.search.facet.Facet and this is where I am stuck. This
interface (Facet) has just two methods (Facet # getName() and Facet #
getType()) and these two methods are not enough to retrieve all the facet
info like the count etc.

Do I need to determine the type of each facet and then type cast it to
specific Facet so that I have more methods available? I am writing some
generic code and hence trying not to do type casting.

Thoughts?

Thanks much!

-Amit.

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

Just cast your Facet with the right class.
See: https://github.com/dadoonet/hands-on/blob/answers/src/test/java/org/elasticsearchfr/handson/ex3/FacetTest.java#L157

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

Le 1 oct. 2013 à 10:05, Amit Soni amitsoni29@gmail.com a écrit :

Hi everyone - I am using Java API client to execute my queries and the request has facets too. After the query has been executed, I receive an instance of org.elasticsearch.action.search.SeachResponse.

However I am unable to retrieve all the factet information from this SearchResponse instance. I tried SearchResponse # getFacets() # getFacets() and this returns me a Map. The key of this map is the facet name which is right and using this I retrieve an instance of org.elasticsearch.search.facet.Facet and this is where I am stuck. This interface (Facet) has just two methods (Facet # getName() and Facet # getType()) and these two methods are not enough to retrieve all the facet info like the count etc.

Do I need to determine the type of each facet and then type cast it to specific Facet so that I have more methods available? I am writing some generic code and hence trying not to do type casting.

Thoughts?

Thanks much!

-Amit.

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

David - Thanks much for the prompt response!

Actually on my server side (since I am writing some generic code), I am
trying to understand what a right design should be since I do not know the
specific Facet class. So in order to cast it, I would need to additionally
store the facet name <--> Facet class mapping which would allow me to
determine the right Facet class. Does this look like a right way?

-Amit.

On Tue, Oct 1, 2013 at 1:12 AM, David Pilato david@pilato.fr wrote:

Just cast your Facet with the right class.
See:
https://github.com/dadoonet/hands-on/blob/answers/src/test/java/org/elasticsearchfr/handson/ex3/FacetTest.java#L157

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet https://twitter.com/dadoonet | @elasticsearchfrhttps://twitter.com/elasticsearchfr
| @scrutmydocs https://twitter.com/scrutmydocs

Le 1 oct. 2013 à 10:05, Amit Soni amitsoni29@gmail.com a écrit :

Hi everyone - I am using Java API client to execute my queries and the
request has facets too. After the query has been executed, I receive an
instance of org.elasticsearch.action.search.SeachResponse.

However I am unable to retrieve all the factet information from this
SearchResponse instance. I tried SearchResponse # getFacets() #
getFacets() and this returns me a Map. The key of this map is the facet
name which is right and using this I retrieve an instance of
org.elasticsearch.search.facet.Facet and this is where I am stuck. This
interface (Facet) has just two methods (Facet # getName() and Facet #
getType()) and these two methods are not enough to retrieve all the facet
info like the count etc.

Do I need to determine the type of each facet and then type cast it to
specific Facet so that I have more methods available? I am writing some
generic code and hence trying not to do type casting.

Thoughts?

Thanks much!

-Amit.

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

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

No need for a class mapping. Each facet carries the facet name. Just keep a
list of facet classes for iteration over getFacets() you used to build the
query with the facet factories, e.g. FacetBuilders.termsFacet("facetname")

Jörg

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