Customizing DatafariUI - QueryFacet
Valid from Datafari 5.1 (UI 1.0.0-beta-0.6.0)
checked for UIv2 1.0
A query facet displays a facet tied to provided queries with the possibility to filter results based on those queries. It can include children components, providing the ability for the user to provide a custom query. In the example below, we present a way to provide a custom date range.
It looks like this:
It is usually used on the left column.
The definition of a query facet looks like the following (Complete configuration file):
{
"type": "QueryFacet",
"title": "Creation Date",
"queries": [
"creation_date:[NOW/DAY TO NOW]",
"creation_date:[NOW/DAY-7DAY TO NOW/DAY]",
"creation_date:[NOW/DAY-30DAY TO NOW/DAY-8DAY]",
"creation_date:([1970-09-01T00:01:00Z TO NOW/DAY-31DAY] || [* TO 1970-08-31T23:59:59Z])",
"creation_date:[1970-09-01T00:00:00Z TO 1970-09-01T00:00:00Z]"
],
"labels": [
"Today",
"From Yesterday Up To 7 days",
"From 8 Days Up To 30 days",
"Older than 31 days",
"No date"
],
"id": "date_facet",
"minShow": 5,
"children": [
{
"type": "DateFacetCustom"
}
]
}
Parameters:
title: the title showed at the top of the facet
queries: the solr queries to execute for the facet
labels: The labels to be shown to the users alongside each query result
id: an internal unique identifier that you must specify
minShow: The maximum number of elements that are shown if the facet is not expanded
maxShow: The maximum number of elements that are shown if the facet is expanded (after clicking show more)
children: an array of children components displayed directly below this facet. Made available to specify components allowing users to specify custom queries, like the one to specify a custom date range shown in the example
show (optional) : True to display the facet. False to hide the facet
variant (optional, default is `both') : differ the display according to the given variant value. It could be :
queries_only
: Only display solr queries as multiple checkboxes listchildren_only
: only display the children component contained in thechildren
props of the QueryFacetboth
(default) : Display both queries list and children components
“children” key - Date facet use case
The 2 Date QueryFacets allow users to specify a custom date range applied to a Solr date field (like creation_date
or last_modified
).
Looks like this:
defined like this for Creation date:
// For creation date
{
"type": "DateFacetCustom"
}
// For Modification date
{
"type": "DateFacetModificationDateCustom"
}
Has no parameters.
DateFacetCustom
and DateFacetModificationDateCustom
are existing React Components. If you want to create new query facets refers, you will need code modification. Refer to our documentation: