[
https://issues.apache.org/jira/browse/OAK-3847?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15091801#comment-15091801
]
Tommaso Teofili edited comment on OAK-3847 at 1/11/16 11:35 AM:
----------------------------------------------------------------
after offline talk with [~chetanm] we have tweaked the proposal to have e.g. a
{{FacetResult}} class (living in _oak-core_) that will wrap the {{QueryResult}}
and will provide access to facets data via POJOs:
{code}
String sql2 = "select [jcr:path], [rep:facet(text)] from [nt:base] " +
"where contains([text], 'hello OR hallo') order by [jcr:path]";
Query q = qm.createQuery(sql2, Query.JCR_SQL2);
QueryResult queryResult = q.execute();
FacetResult facetResult = new FacetResult(queryResult);
String[] dimensions = facetResult.getDimensions(); // { "text" }
for (String dimension : dimensions) {
List<Facet> facets = facetResult.getFacets(dimension);
for (Facet facet : facets) {
System.out.println(facet.getLabel() + ":" + facet.getCount());
}
}
{code}
I'll follow up with a structured proposal for the {{FacetResult}} API.
was (Author: teofili):
after offline talk with [~chetanm] we have tweaked the proposal to have e.g. a
{{FacetResult}} class (living in _oak-core_) that will wrap the {{QueryResult}}
and will provide access to facets data via POJOs:
{code}
String sql2 = "select [jcr:path], [rep:facet(text)] from [nt:base] " +
"where contains([text], 'hello OR hallo') order by [jcr:path]";
Query q = qm.createQuery(sql2, Query.JCR_SQL2);
QueryResult queryResult = q.execute();
FacetResult facetResult = new FacetResult(queryResult);
String[] dimensions = facetResult.getDimensions(); // { "text" }
for (String dimension : dimensions) {
List<Facet> facets = facetResult.getFacets(dimension);
for (Facet facet : facets) {
System.out.println(facet.getLabel() + ":" + facet.getCount());
}
}
{code}
> Provide an easy way to parse/retrieve facets
> --------------------------------------------
>
> Key: OAK-3847
> URL: https://issues.apache.org/jira/browse/OAK-3847
> Project: Jackrabbit Oak
> Issue Type: Improvement
> Components: lucene, solr
> Reporter: Tommaso Teofili
> Assignee: Tommaso Teofili
> Fix For: 1.3.14
>
>
> Current facet results are returned within the rep:facet($propertyname)
> property of each resulting node. The resulting String [1] is however a bit
> annoying to parse as it separates label / value by comma so that if label
> contains a similar pattern parsing may even be buggy.
> An easier format for facets should be used, eventually together with an
> utility class that returns proper objects that client code can consume.
> [1] :
> https://github.com/apache/jackrabbit-oak/blob/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/jcr/query/FacetTest.java#L99
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)