How do I enable facets to be returned in my JSON or XML search results?

The query parameters for enabling facets on fields output in XML/JSON are as follows:

Terms Facets

facet=on
facet.field=keywords (If keywords is the field you want to facet.)

Example:
<pre>http://localhost:8080/searchblox/servlet/SearchServlet?facet=on&query=time&facet.field=keywords</pre>
f.keywords.size=5 (You can control the number of facets returned by passing the value in the parameter.)

Default number of categories for the facet is **10**

Example, with one facet and size setting:
<pre>http://localhost:8080/searchblox/servlet/SearchServlet?facet=on&query=time&facet.field=keywords&f.keywords.size=25</pre>

When you click on a category for a facet, the query to be passed to SearchBlox is as follows:

Example, with one facet and filter applied:
<pre>http://localhost:8080/searchblox/servlet/SearchServlet?facet=on&query=time&facet.field=keywords&f.keywords.size=25&f.keywords.filter=travel</pre>

Example, with 2 facets and 2 filters applied:
<pre>http://localhost:8080/searchblox/servlet/SearchServlet?facet=on&query=time&facet.field=CPS_SECTION_PATH&facet.field=keywords&f.keywords.size=5&f.CPS_SECTION_PATH.size=15&f.keywords.filter=bbc&f.CPS_SECTION_PATH.filter=data</pre>

Range Facets (Only applies to numbers and dates.)

facet.field=size
f.size.range=[*TO100000]
f.size.range=[100001TO*]

Example for number range facet:<pre>http://localhost:8080/searchblox/servlet/SearchServlet?facet=on&query=time&facet.field=CPS_SECTION_PATH&facet.field=keywords&f.keywords.size=5&f.CPS_SECTION_PATH.size=15&f.keywords.filter=bbc&f.CPS_SECTION_PATH.filter=data&facet.field=size&f.size.range=[*TO100000]&f.size.range=[100001TO*]</pre>

Date Range Facet

facet.field=indexdate
f.indexdate.range=[*TO2012-02-28T00:00:26]

Example for date range faceting:
<pre>http://localhost:8080/searchblox/servlet/SearchServlet?facet=on&query=time&facet.field=CPS_SECTION_PATH&facet.field=keywords&f.keywords.size=5&f.CPS_SECTION_PATH.size=15&f.keywords.filter=bbc&f.CPS_SECTION_PATH.filter=data&facet.field=size&f.size.range=[*TO100000]&&f.size.range=[100001TO*]&facet.field=indexdate&f.indexdate.range=[*TO2012-02-28T00:00:26]</pre>

Date Histogram Facets

facet.field=indexdate
**Possible Values**
f.indexdate.interval=week
f.indexdate.interval=day
f.indexdate.interval=month
f.indexdate.interval=year
f.indexdate.interval=hour
f.indexdate.interval=minute

Examples for date histogram:
<pre>http://localhost:8080/searchblox/servlet/SearchServlet?facet=on&query=time&facet.field=CPS_SECTION_PATH&facet.field=keywords&f.keywords.size=5&f.CPS_SCTION_PATH.size=15&f.keywords.filter=bbc&f.CPS_SECTION_PATH.filter=data&facet.field=size&f.size.range[*TO100000]&&f.size.range=[100001TO*]&facet.field=indexdate&f.indexdate.interval=week</pre>

<pre>http://localhost:8080/searchblox/servlet/SearchServlet?facet=on&query=time&facet.field=CPS_SECTION_PATH&facet.field=keywords&f.keywords.size=5&f.CPS_SECTION_PATH.size=15&f.keywords.filter=bbc&f.CPS_SECTION_PATH.filter=data&facet.field=size&f.size.range=[*TO100000]&&f.size.range=[100001TO*]&facet.field=indexdate&f.indexdate.interval=month</pre>

Have more questions? Submit a request

Comments