Range faceting

Range faceting can be done on date fields and numeric fields.

Range faceting parameters:

Parameter

Behavior

Default value

facet.range

Specifies the field for which Solr should create range facets. For example:

facet.range=salary&facet.range=rank

facet.range=createdDate

facet.range.start

Specifies from where (lower bound) the range starts. For example:

f.salary.facet.range.start=10000.0&f.rank.facet.range.start=1

f.createdDate.facet.range.start=NOW/DAY-30DAYS

facet.range.end

Specifies where (upper bound) the range ends. For example:

f.salary.facet.range.end=100000.0&f.rank.facet.range.end=50

f.createdDate.facet.range.end=NOW/DAY+30DAYS

facet.range.gap The size of each range will be added to the lower bound successively until the upper bound is reached.
facet.range.hardend

A Boolean parameter that specifies how Solr should handle cases where facet.range.gap does not divide evenly between lower bound and upper bound.

If it is true, the last range constraint will have the facet.range.end value as an upper bound. If false, the last range will have the smallest possible upper bound greater than facet.range.end such that the range is the exact width of the specified range gap.

false
facet.range.include

Determines how to compute range faceting between the lower bound and upper bound. Possible values are:

  • lower: All gap-based ranges include their lower bound
  • upper: All gap-based ranges include their upper bound
  • edge: The first and last gap ranges include their edge bounds (lower for the first one, upper for the last one) even if the corresponding upper/lower option is not specified
  • outer: The before and after ranges will be inclusive of their bounds even if the first or last ranges already include those boundaries
  • all: Includes all options—lower, upper, edge, and outer.
facet.range.other

Specifies that, in addition to the counts for each range between lower bound and upper bound, counts should be computed for these options as well:

  • before: All records with field values lower than lower bound of the first range
  • after: All records with field values greater than the upper bound of the last range
  • between: All records with field values between the start and end bounds of all ranges
  • none: Do not compute any counts
  • all: Compute counts for before, between, and after
facet.range.method

Specifies a faceting method:

  • filter: Generates the ranges based on other facet.range parameters.
  • div: Iterates all the documents that match the main query, and for each of them, it finds the correct range for the value. Not supporting for DateRangeField field type or when we have used group.facets.
filter

 

Example: Search query for iPod with faceting enabled and range for the field price from 1000 to 100000

URLhttp://localhost:8983/solr/techproducts/select?defType=edismax&q=ipod&fl=id,name,price&facet=true&facet.range=price&facet.range.start=10&facet.range.end=20&facet.range.gap=5

Response:

{
"responseHeader":{
"status":0,
"QTime":1,
"params":{
"facet.range":"price",
"q":"ipod",
"defType":"edismax",
"facet.range.gap":"5",
"fl":"id,name,price",
"facet":"true",
"facet.range.start":"10",
"facet.range.end":"20"}},
"response":{"numFound":3,"start":0,"docs":[
{
"id":"IW-02",
"name":"iPod & iPod Mini USB 2.0 Cable",
"price":11.5},
{
"id":"F8V7067-APL-KIT",
"name":"Belkin Mobile Power Cord for iPod w/ Dock",
"price":19.95},
{
"id":"MA147LL/A",
"name":"Apple 60 GB iPod with Video Playback Black",
"price":399.0}]
},
"facet_counts":{
"facet_queries":{},
"facet_fields":{},
"facet_ranges":{
"price":{
"counts":[
"10.0",1,
"15.0",1],
"gap":5.0,
"start":10.0,
"end":20.0}},
"facet_intervals":{},
"facet_heatmaps":{}}}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.59.6.153