[
https://issues.apache.org/jira/browse/SOLR-12981?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16681755#comment-16681755
]
Jason Gerlowski commented on SOLR-12981:
----------------------------------------
The attached patch creates an object called "JsonFacetingResponse" that
supports navigating faceting results. General outline:
{code}
*JsonFacetingResponse*
int getCount()
Object getVal()
List<JsonFacetingResponse> getFacetResultsByName(String name)
Double getStatFacetResultsByName(String name);
{code}
Some general notes/pros/cons:
- JsonFacetingResponse is recursive- it represents the top-level faceting
response, but it's also used to represent individual facet-buckets (which
themselves can have subfacets, etc.)
- it parses keys "count", and "val", and then treats any other JSON keys as the
names of subfacets. This is a misstep with some facet-types which have
optional keys/statistics (e.g. the numBuckets stat that is optionally computed
for "terms" facets). Partially to blame for this is that it's difficult to
look at the JSON faceting response and know what sort of facet we're parsing
the results of. If we had a reliable way to differentiate e.g. a "terms"
response bucket from a "range" response bucket, we could change the interfaces
in SolrJ to be a little more helpful. For example we could let users do things
like:
({{facetingResponse.getTermFacetResultsByName("categories").getNumBuckets()}}).
Musing aloud, I wonder how reasonable it'd be to add a "type" property to each
facet bucket. That'd make parsing and allowing access to this stuff much
easier.
- The response for heatmap facets is very different from the others. The
current WIP patch doesn't handle it currently, but there's no real blocker for
implementing it.
> Better support JSON faceting responses in SolrJ
> -----------------------------------------------
>
> Key: SOLR-12981
> URL: https://issues.apache.org/jira/browse/SOLR-12981
> Project: Solr
> Issue Type: Sub-task
> Security Level: Public(Default Security Level. Issues are Public)
> Components: clients - java, SolrJ
> Affects Versions: 7.5, master (8.0)
> Reporter: Jason Gerlowski
> Assignee: Jason Gerlowski
> Priority: Major
> Attachments: SOLR-12981.patch
>
>
> SOLR-12947 created JsonQueryRequest to make using the JSON request API easier
> in SolrJ. SOLR-12965 is adding faceting support to this request object.
> This subtask of SOLR-12965 involves providing a way to parse the JSON
> faceting responses into easy-to-use SolrJ objects.
> Currently the only option for users is to manipulate the underlying NamedList
> directly. We should create a "JsonFacetingResponse" in the model of
> ClusteringResponse, SuggesterResponse, TermsResponse, etc. and add an
> accessor to {{QueryResponse}} for getting at the faceting results.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]