Hi Reto,
You can use the featured search by constructing a SolrQuery using the
facet names and values as in the following example:
SolrQuery query = new SolrQuery();
query.setQuery("a*");
query.addFilterQuery(<facetName> + ":"+
ClientUtils.escapeQueryChars(<facetValue>));
featuredSearch.search(query);
You can obtain facet values by:
for (Count count : facetResult.getFacetField().getValues()) {
String facetValue = count.getName();
long documentCount = count.getCount();
}
Based on the types of results facets e.g int, double, date, etc. you can
write range queries. Type of a facet can be obtained by:
facetResult.getType();
You can have a look at solr query syntax for range queries at [1].
Best,
Suat
[1] http://wiki.apache.org/solr/SolrQuerySyntax
On 04/05/2012 01:14 PM, Reto Bachmann-Gmür wrote:
> Hello
>
> I'm trying to programmatically access the facetted browsing features. I got
> the first step, getting the top level categories with:
>
> SearchResult searchResult = featuredSearch.search("a*");
> List<FacetResult> facetResults = searchResult.getFacets();
> for (FacetResult fr : facetResults) {
> final String name = fr.getFacetField().getName();
> System.out.println("name: "+name);
> }
>
> How do I get the faceted search entries in the enumerated categories, and
> how do I apply such an entry, how do I get the matching content items?
>
> Cheers,
> Reto
>