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.
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.
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:
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.
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")
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.