Faceting Drill Down
  • 14 Oct 2021
  • 1 Minute to read
  • Dark
    Light

Faceting Drill Down

  • Dark
    Light

Article summary

Narrowing the scope of your query can be done by adding the fq parameter to narrow the search. You can use the Boolean syntax for numbers and dates as described in the Query Syntax Guide.

The reason &facets and &fq parameters are distinct (&facets does not imply &fq) is that an ajax-style client might want to run multiple queries, and generate the attendant counts, without necessarily narrowing the query for each one. Logic that builds a tree-view and lazily expands it when a user clicks, but that maintains counts for levels other than the most expanded one, depends on this sort of behavior.

If you only want facet counts, and not any hits, you can use &limit=0 to make the <hits> section of your response empty; the facets section is still populated.

The fq parameter can be used to help keep track of breadcrumbs, as the fq is reserved for facet selections. When the user drills in, a new item is added to &fq; when the user backs out, that item can be removed. The XML response includes <fq>...</fq> anytime &fq is used in the request URL.

Here is a sample query that would return 1,000 hits. The counts associated with each bin sum to 1,000 within a particular facet. This is before a user drills into a particular bin to narrow the search.

Example:

Assumes the date is 08/13/2012

https://<appliance_ip>/search?q=data&facets=lastmodified:range(begin:-2years, end:today, gap:{-7 days, -1 month, -2 years}),contentlength:range(begin:0, end:4G, gap:{50k, 1M, 25M, 100M, 4G})

Response:

<facets> 
  <facet name="lastmodified" type="date"> 
    <bins> 
      <bin range="[2010-08-13 TO 2012-07-13}">401</bin> 
      <bin range="[2012-07-13 TO 2012-08-06}">509</bin> 
      <bin range="[2012-08-06 TO 2012-08-13}">0</bin> 
    </bins> 
  </facet> 
  <facet name="contentlength" type="number"> 
    <bins> 
      <bin range="[0 TO 51200}">900</bin> 
      <bin range="[51200 TO 1048576}">75</bin> 
      <bin range="[1048576 TO 26214400}">25</bin> 
      <bin range="[26214400 TO 104857600}">0</bin> 
      <bin range="[104857600 TO 4294967296}">0</bin> 
    </bins> 
  </facet> 
</facets>

Here is the same query and results with the fq parameter added in, narrowing the criteria and effectively drilling in to the original results.

Example:

https://<appliance_ip>/search?q=data&space=0&facets=lastmodified:range(begin:-2years, end:today, gap:{-7 days, -1 month, -2 years}),contentlength:range(begin:0, end:4G, gap:{50k, 1M, 25M, 100M, 4G})&fq=lastmodified:([2010-08-13 TO 2012-07-13]),contentlength:([0 TO 51200])

Response:

<facets> 
  <facet name="lastmodified" type="date"> 
    <bins> 
      <bin range="[2010-08-13 TO 2012-07-13}">401</bin> 
      <bin range="[2012-07-13 TO 2012-08-06}">0</bin> 
      <bin range="[2012-08-06 TO 2012-08-13}">0</bin> 
    </bins> 
  </facet> 
  <facet name="contentlength" type="number"> 
    <bins> 
      <bin range="[0 TO 51200}">401</bin> 
      <bin range="[51200 TO 1048576}">0</bin> 
      <bin range="[1048576 TO 26214400}">0</bin> 
      <bin range="[26214400 TO 104857600}">0</bin> 
      <bin range="[104857600 TO 4294967296}">0</bin> 
    </bins> 
  </facet> 
</facets>

Was this article helpful?