Customizing top left logo and background image
Note |
---|
Info |
This documentation is complemented by the https://gitlab.datafari.com/datafari-community/DatafariUI/-/blob/dev/README.md that gives you more indepth details for low level modifications of DatafariUI, in particular those that require rebuilding the framework. |
Info |
---|
The documentation below is valid from November 5th 2021 or from commit dbb8d17e6a35b5a313e4086e0b04fffaaa94a24c of the DatafariUI repository. |
Table of content
Table of Contents | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Customizing top left logo and background image
The top left logo is a public file which path from the root installation of DatafariUI is:
...
You can change it to put any png file containing your logo. Note that you MUST keep the naming (and hence you must use the png format).
If you are using DatafariUI bundled with Datafari and the default installation path, the file is located at:
...
You can change it to put any png file containing your logo. Note that you MUST keep the naming (and hence you must use the png format).
If you are using DatafariUI bundled with Datafari and the default installation path, the file is located at:
...
This image should be minimum 1920px width and max 65px height. Note that you MUST keep the naming (and hence you must use the png format).
Customizing Displayed Facets and Elements
Note |
---|
This documentation is valid from November 5th 2021 or from commit a6a7479fe6ea281de3ac4505ace56fecd043c12f of the DatafariUI repository. |
It is possible to customize the facets displayed as well as some of the elements displayed in DatafariUI by modifying a configuration file. This configuration file is ui-config.json
and is present in the public
folder of the DatafariUI project.
...
Code Block | ||
---|---|---|
| ||
{ "left": [ { "type": "FieldFacet", "title": "Extension", "field": "extension", "op": "OR", "minShow": 2, "maxShow": 5 }, { "type": "FieldFacet", "title": "Language", "field": "language", "op": "OR", "minShow": 2, "maxShow": 5 }, { "type": "FieldFacet", "title": "Source", "field": "repo_source", "op": "OR", "minShow": 2, "maxShow": 5, "show": false }, { "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" } ] }, { "type": "HierarchicalFacet", "field": "urlHierarchy", "title": "hierarchical facet", "separator": "/" }, { "type": "AggregatorFacet", "title": "Aggregator facet" } ], "center": { "main": [ { "type": "SearchInformation", "data": ["filters", "facets"] }, { "type": "ResultsList", "data": ["title", "url", "logo", "previewButton", "extract"], "folderLinkSources": ["enron"], "folderTarget": "_blank", "previewTarget": "_self" } ], "tabs": [ { "type": "FieldFacet", "field": "repo_source", "max": 3 } ] }, "right": [], "searchBar": { "suggesters": [ { "type": "BASIC", "props": { "maxSuggestion": 5, "title": "SUGGESTED QUERIES", "subtitle": "Queries extending your current query terms" }, "aggregator": false }, { "type": "ENTITY", "props": { "field": "authorTokens", "suggester": "suggestAuthors", "dictionary": "suggesterEntityAuthors", "asFacet": false, "maxSuggestion": 5, "title": "Entities suggested", "subtitle": "Queries extending your current query terms" } } ] }, "queryParams": { "fields": [ "title", "url", "id", "extension", "preview_content", "last_modified", "crawl_date", "author", "original_file_size", "emptied", "repo_source" ] }, "hotkeys": { "activeSearchBar": { "cmd": "shift", "key": "S", "enable": false }, "deactiveSearchBar": { "cmd": "escape", "enable": false } }, "devMode": { "enable": false, "banner": { "location": "BOTTOM", "content": "Dev mode banner content", "props": { "backgroundColor": "orange" } } } } |
...
Code Block | ||
---|---|---|
| ||
{ "type": "FieldFacet", "title": "Extension", "field": "extension", "op": "OR", "minShow": 2, "maxShow": 5, "show": true, "sendToSolr": true }, |
Parameters
Name | Optional | Default value | Description |
---|---|---|---|
| The title showed at the top of the facet | ||
| The solr field associated to the facet | ||
| Operator, either “OR” or “AND”. Tells how documents are shown when selecting multiple entries in the facet. If “OR” documents need to have at least one selected element in the concerned field to be selected. If “AND” they need to have all selected elements as part of the concerned field | ||
| The maximum number of elements that are shown if the facet is not expanded | ||
| The maximum number of elements that are shown if the facet is expanded (after clicking show more) | ||
| yes | checkbox | Specify the type of FieldFacet to use. It can take these values :
|
| yes | true | True to display the FieldFacet in the left panel. This option is only an UI effect. The facet is still registered as a field facet in the query. |
| yes | false | Set to true to force the query to Solr even if show is false (keep in mind that if show is true, the facet is queried whatever the value of the sendToSolr parameter). Required to be true for the use of field facet tabs (https://datafari.atlassian.net/wiki/spaces/DATAFARI/pages/2625634305/Customizing+DatafariUI#Search-Tabs ), which is its only purpose for now. |
QueryFacet:
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.
...
Code Block | ||
---|---|---|
| ||
{ "type": "AggregatorFacet", "title": "Aggregator facet", "show": false } |
Parameters:
title: the title showed at the top of the facet
SearchInformation
Displays some information about the current search, such as:
currently searched terms
spell checking information if available as well as automatic spell checking query firing if 0 results were found
filters applied
facet filters applied
It looks like this:
...
The definition looks like:
...
language | json |
---|
...
show: show or hide this facet
Quick Links widget
Widget to display links to quickly navigate to useful content.
...
It is usually used in the right column. The widget definition looks like this:
Code Block |
---|
{ "type": "SearchInformationDirectLinksWidget", "datatitle": ["filtersDirect Links", "facets"]show": true visible: 1 }, |
Parameters:
data: An array of data to be displayed. Possible values:
“filters”: displays the “other filters” section if present
“facets”: displays the facets in the filters section if present
The current search and spellcheck info are always displayed if this component is used.
Search Tabs
The UI configuration allows to add graphical tabs below the search bar, between the All content tab and the Search Tools tab.
As of the writing of this documentation (March 2022), we propose two types of tabs :
FieldFacet
: it will generate as many tabs as a field contains out of a result query. For example, with the "extension" field in our demo, it will create one tab per type of extension returned by the search query (for instance one tab for the pdf type, one for the doc type etc).
This type of tab has two parameters :field
: the field name used to generate the tabsmax
: the max number of tabs that can be generatedRaw
: This type of tab is called raw because it is just a link to a given URL. It has 2 parameters :label
: the label of the tab (it is i18n)url
: an HTTP URL.target
: (optional) define where to open the url. If absent, default is _self. Values accepted: _self OR _blank
These tabs can be declared as illustrated below in the ui-config.json,
in the center property :
...
language | json |
---|
...
type
- The type of component to place in the servicetitle
- The title showed at the top of the facetshow
- Custom parameter, default value is true
. true
- for will enable the display of the "Direct Links" widget in the right pane. false
- to hide its display in the service. This option is just a user interface effect. The widget is still registered with the service.visible
- Custom parameter, default value is 10
. Specifies the maximum number of records that will be immediately visible when the widget is displayed
Yellow Page widget
Widget to display useful contact information
...
It is usually used in the right column. The widget definition looks like this:
Code Block |
---|
{
"type": "YellowPagesWidget",
"title": "Yellow Pages",
"show": true
visible: 1
} |
Options:
type
- The type of component to place in the servicetitle
- The title showed at the top of the facetshow
- Custom parameter, default value is true
. true
- for will enable the display of the "Yellow Pages" widget in the right pane. false
- to hide its display in the service. This option is just a user interface effect. The widget is still registered with the service.visible
- Custom parameter, default value is 1
. Specifies the maximum number of records that will be immediately visible when the widget is displayed
SearchInformation
Displays some information about the current search, such as:
currently searched terms
spell checking information if available as well as automatic spell checking query firing if 0 results were found
filters applied
facet filters applied
It looks like this:
...
The definition looks like:
Code Block | ||
---|---|---|
| ||
{ "type": "SearchInformation", { "typedata": ["Rawfilters", "labelfacets": "google", "url": "https://www.google.fr" }, { "type": "Raw", "label": "LinkedIn", "url": "https://www.linkedin.com" } ] } |
Note |
---|
A field tab is based on a facet, one of those defined in the |
Here is an example :
Code Block | ||
---|---|---|
| ||
{ "left": [ { "type": "FieldFacet", "title": "Extension", "field": "extension", "op": "OR", "minShow": 2,] } |
Parameters:
data: An array of data to be displayed. Possible values:
“filters”: displays the “other filters” section if present
“facets”: displays the facets in the filters section if present
The current search and spellcheck info are always displayed if this component is used.
Search Tabs
The UI configuration allows to add graphical tabs below the search bar, between the All content tab and the Search Tools tab.
As of the writing of this documentation (March 2022), we propose two types of tabs :
FieldFacet
: it will generate as many tabs as a field contains out of a result query. For example, with the "extension" field in our demo, it will create one tab per type of extension returned by the search query (for instance one tab for the pdf type, one for the doc type etc).
This type of tab has two parameters :field
: the field name used to generate the tabsmax
: the max number of tabs that can be generatedRaw
: This type of tab is called raw because it is just a link to a given URL. It has 2 parameters :label
: the label of the tab (it is i18n)url
: an HTTP URL.target
: (optional) define where to open the url. If absent, default is _self. Values accepted: _self OR _blank
These tabs can be declared as illustrated below in the ui-config.json,
in the center property :
Code Block | ||
---|---|---|
| ||
"center": { "main": [ { "maxShowtype": 5"SearchInformation", "showdata": false ["filters", "facets"] }, { "type": "FieldFacetResultsList", "titledata": ["Languagetitle", "field":"url", "languagelogo", "oppreviewButton":, "ORextract",] } "minShow": 2, ], "maxShowtabs": 5[ }, { "type": "FieldFacet", "type": "FieldFacet""field": "extension", "max": 3 }, { "titletype": "SourceFieldFacet", "field": "repo_source", "opmax": "OR"3 }, { "minShowtype": 2, "maxShow": 5 } ], "center": { "main": ["Raw", "label": "google", "url": "https://www.google.fr" }, { "type": "SearchInformationRaw", "datalabel": ["filtersLinkedIn", "facetsurl"] },: "https://www.linkedin.com" } ] { "type": "ResultsList", "data": ["title", "url", "logo", "previewButton", "extract"], "folderLinkSources": [], } |
Note |
---|
A field tab is based on a facet, one of those defined in the |
Here is an example :
Code Block | ||
---|---|---|
| ||
{ "left": [ { "folderTargettype": "_blankFieldFacet", "previewTargettitle": "_selfExtension", } "field": "extension", ], "op": "tabsOR":, [ { "typeminShow": "FieldFacet",2, "fieldmaxShow": "extension",5, "maxshow": false 3 }, { { "type": "FieldFacet", "fieldtitle": "repo_sourceLanguage", "max": 3 } "field": "language", ] }, "rightop": []"OR", "searchBarminShow": 2, { "suggestersmaxShow": 5 [] } } |
Note the repo_source field
defined in the FieldFacet tab is also declared as the field
parameters of a FieldFacet facet in the left section.
...
ResultsList
Shows the list of results.
Looks like this:
...
The definition looks like this, in ui-config.json
Code Block | ||
---|---|---|
| ||
{ , { "type": "ResultsListFieldFacet", "datatitle": ["titleSource", "url", "logo", "previewButton", "extract"] "field": "repo_source", "folderLinkSources": [], "folderTargetop": "_blankOR", "previewTarget "minShow": "_self" } |
Parameters:
data
: An array of data to be displayed. Possible values:title
: Displays the document title for each result if presenturl
: Displays the url for each result if presentlogo
: Displays the file type logo for each result if presentpreviewButton
: Displays the preview button for each result if presentextract
: Displays the text snippet with highlighting for each result if present
folderLinkSource
(default is an empty array[]
in which case nothing will be displayed) : array of sources to open as a folder. Needs to match with sources declared (case sensitive). For instance, if you have a source named “Enron”, the array should be["Enron"]
folderTarget
(optional, default is_blank
): target to open folder. Values are the same as the HTML attributetarget
. The values you can declare mandatorily come from the repo_source solr field, displayed via the source facet field to users.previewTarget
(optional, default_self
): target to open preview page. Values are the same as the HTML attributetarget
.
Any data not present is not displayed. If the data parameter is absent or is not an array, the default (showing everything) is used. Values other than the one given above are ignored. An empty array results in the following (Yes this is useless but possible):
...
Range Facet
Note |
---|
This facet is still in development as of March 15th, 2022 |
Range Facet is a facet that displays a bar chart with a range selection tool. It is a generic react component that could be used to display any kind of dual axis data.
...
From ui-config.json
file, you can customize the following parameters of the chart :
...
Name
...
Description
...
type
...
Facet type set to RangeFacet
...
title
...
i18n facet title
...
field
...
Solr field to bind
...
start
...
Solr range start
...
end
...
Solr range end
...
gap
...
Solr range gap
...
yDataKey
...
Key used to format data and used to display the Y bar legend. Key is i18n.
...
ranges (Optional)
...
Array of predefined integer ranges to get as much as radio button selection to give to the brush tool a predefined range. Default is an empty array and the ranges controls are hidden.
...
rangeLabel (Optional)
...
i18n label next to range value
...
showBrushBounds (Optional)
...
true
to display the brush bounds under the brush tool. Default is false
...
barFillColor (Optional)
...
Bar fill color. Default is #679439AA
(smooth green)
...
brushStrokeColor (Optional)
...
brush stroke color (range selection tool under the graph). Default is #679439
(smooth green)
Configuration example include in left facet :
Code Block | ||
---|---|---|
| ||
"left": [ { "type": "FieldFacet", "title": "Extension", "field": "extension", "2, "maxShow": 5 } ], "center": { "main": [ { "type": "SearchInformation", "data": ["filters", "facets"] }, { "type": "ResultsList", "data": ["title", "url", "logo", "previewButton", "extract"], "folderLinkSources": [], "folderTarget": "_blank", "previewTarget": "_self" } ], "tabs": [ { "type": "FieldFacet", "field": "extension", "max": 3 }, { "type": "FieldFacet", "field": "repo_source", "max": 3 } ] }, "right": [], "searchBar": { "suggesters": [] } } |
Note the repo_source field
defined in the FieldFacet tab is also declared as the field
parameters of a FieldFacet facet in the left section.
...
ResultsList
Shows the list of results.
Looks like this:
...
The definition looks like this, in ui-config.json
Code Block | ||
---|---|---|
| ||
{
"type": "ResultsList",
"data": ["title", "url", "logo", "previewButton", "extract"],
"folderLinkSources": [],
"folderTarget": "_blank",
"previewTarget": "_self"
} |
Parameters:
data
: An array of data to be displayed. Possible values:title
: Displays the document title for each result if presenturl
: Displays the url for each result if presentlogo
: Displays the file type logo for each result if presentpreviewButton
: Displays the preview button for each result if presentextract
: Displays the text snippet with highlighting for each result if present
folderLinkSource
(default is an empty array[]
in which case nothing will be displayed) : array of sources to open as a folder. Needs to match with sources declared (case sensitive). For instance, if you have a source named “Enron”, the array should be["Enron"]
folderTarget
(optional, default is_blank
): target to open folder. Values are the same as the HTML attributetarget
. The values you can declare mandatorily come from the repo_source solr field, displayed via the source facet field to users.previewTarget
(optional, default_self
): target to open preview page. Values are the same as the HTML attributetarget
.
Any data not present is not displayed. If the data parameter is absent or is not an array, the default (showing everything) is used. Values other than the one given above are ignored. An empty array results in the following (Yes this is useless but possible):
...
Range Facet
Note |
---|
This facet is still in development as of March 15th, 2022 |
Range Facet is a facet that displays a bar chart with a range selection tool. It is a generic react component that could be used to display any kind of dual axis data.
...
From ui-config.json
file, you can customize the following parameters of the chart :
Name | Description |
---|---|
type | Facet type set to |
title | i18n facet title |
field | Solr field to bind |
start | Solr range start |
end | Solr range end |
gap | Solr range gap |
yDataKey | Key used to format data and used to display the Y bar legend. Key is i18n. |
ranges (Optional) | Array of predefined integer ranges to get as much as radio button selection to give to the brush tool a predefined range. Default is an empty array and the ranges controls are hidden. |
rangeLabel (Optional) | i18n label next to range value |
showBrushBounds (Optional) |
|
barFillColor (Optional) | Bar fill color. Default is |
brushStrokeColor (Optional) | brush stroke color (range selection tool under the graph). Default is |
Configuration example include in left facet :
Code Block | ||
---|---|---|
| ||
"left": [
{
"type": "FieldFacet",
"title": "Extension",
"field": "extension",
"op": "OR",
"minShow": 2,
"maxShow": 5
},
{
"type": "FieldFacet",
"title": "Language",
"field": "language",
"op": "OR",
"minShow": 2,
"maxShow": 5
},
{
"type": "FieldFacet",
"title": "Source",
"field": "repo_source",
"op": "OR",
"minShow": 2,
"maxShow": 5,
"show": false
},
{
"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"
}
]
},
{
"type": "RangeFacet",
"field": "creation_date",
"start": "NOW-300MONTH",
"end": "NOW/MONTH",
"gap": "+1MONTH",
"title": "Date Range",
"yDataKey": "doc",
"ranges": [1, 3, 6, 12, 36],
"rangeLabel": "Month",
"showBrushBounds": true
},
{
"type": "RangeFacet",
"field": "page_count",
"start": "0",
"end": "99",
"gap": "+1",
"title": "Page count",
"yDataKey": "page",
"ranges": [1, 3, 6, 12, 36],
"rangeLabel": "Page",
"showBrushBounds": true
},
{
"type": "HierarchicalFacet",
"field": "urlHierarchy",
"title": "hierarchical facet",
"separator": "/"
},
{
"type": "AggregatorFacet",
"title": "Aggregator facet"
}
] |
...
The RangeBarChart
component can be embed into any other component like the RangeFacet
that displays the graph as a facet with a maximal height. This component uses the following props :
Prop name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data | Array | an array of objects that represents the data to be displayed in the graph. The minimal object structure must be as follows :
Example :
X labels will be based on With the previous example, the dates are used for X labels.
| |||||||||||||||
xDataKey | string | Name of the field in the data array object for X axis | |||||||||||||||
yDataKey | string | Name of the field in the data array object for Y axis | |||||||||||||||
maxHeight | number|string | Max height of the graph. Default is | |||||||||||||||
width | number|string | Width of the graph. Default is | |||||||||||||||
startIndex | number | Start index of the brush tool | |||||||||||||||
endIndex | number | End index of the brush tool | |||||||||||||||
brushStrokeColor | string | CSS color of the brush tool stroke. Default is | |||||||||||||||
barFillColor | string | CSS color of the chart bar. Default is | |||||||||||||||
xTickFormater | function<value>:string | A function that takes the X axis label value and returns a formatted value. Default is undefined. | |||||||||||||||
brushLabelFormatter | function<value>:string | A function that formats the brush label as you will. Default returns the current value | |||||||||||||||
onSelectChanged | function<startIndex, endIndex>:void | A function called when the user has changed the brush selection. |
Customize Search Bar component
...
The searchBar
has the following parameters :
Name | Description |
---|---|
| Array of suggesters. Several suggesters can be added, even if they are of the same type : you can add 2 entity suggesters but with different field/suggester. Each suggester result will be displayed in a dedicated section below the search bar. Available suggester types and their parameters are presented below |
| Enable / Disabled the backdrop behind the search bar when it is focused. Default is |
Available suggesters
There are 3 types of suggesters :
...
Code Block | ||
---|---|---|
| ||
... "searchBar": { "suggesters": [ { "type": "BASIC", "props": { "maxSuggestion": 5, "title": "SUGGESTED QUERIES", "subtitle": "Queries extending your current query terms", }, "aggregator": false }, { "type": "ENTITY", "props": { "field": "authorTokens", "suggester": "suggestAuthors", "dictionary": "suggesterEntityAuthors", "asFacet": false, "maxSuggestion": 5, "title": "Entities suggested", "subtitle": "Queries extending your current query terms" } } ] } ... |
...
Code Block | ||
---|---|---|
| ||
{ "type": "BASIC", "props": { "maxSuggestion": 5, "title": "SUGGESTED QUERIES", "subtitle": "Queries extending your current query terms" }, "aggregator": false } |
parameters:
maxSuggestion: The maximum number of suggestion that will be showed in the autocomplete for this suggester
title: the title of the autocomplete section for this suggester
subtitle: the subtitle / helper text of the autocomplete section for this suggester
aggregator : indicates if aggregator is activated or not. If yes use the Datafari REST API rest/v2.0/noaggregator/suggest instead of rest/v2.0/suggest
ENTITY suggester
A suggester designed for entity suggestions. Adds to the query a statement like: field:(“suggestion”).
...
field: The field containing the entities
suggester: the solr request handler for that suggester
dictionary: the name of the dictionary used in the suggest handler
asFacet: weather the filter is added to the query body (q= parameter) or as an fq.
maxSuggestion: the maximum number of suggestions showed for this section of the autocomplete
title: the title of the autocomplete section for this suggester
subtitle: the subtitle / helper text of the autocomplete section for this suggester
Adding a new suggester - Configuration
Without the need to recompile Datafari or DatafariUI, you can add new suggesters in the autocomplete just by declaring them in the config file, as long as you do not want to declare a new type of suggester used in the backend (see the next chapter for adding a new type of suggester). You can get the list of currently implemented suggesters types by looking at this file: https://gitlab.datafari.com/datafari-community/DatafariUI/-/blob/dev/src/Components/SearchBar/Autocompletes/Suggester/useSuggesters.js
You also need to add the suggester into the file $DATAFARI_HOME/tomcat/conf/entity-autocomplete.properties see https://datafari.atlassian.net/wiki/spaces/DATAFARI/pages/2681831425/Adding+entity+autocomplete+from+indexation+to+autocomplete#Configuring-Datafari-to-Serve-the-New-Suggest-Request-Handler
In the configuration below, we have 3 suggesters : 1 of type basic and 2 of type entity. The difference between the 2 entities suggesters here, is at the field, the name of the request handler used and titles parameters level, but it could also be at the subtitle level.
...
language | json |
---|
...
body (q= parameter) or as an fq.
maxSuggestion: the maximum number of suggestions showed for this section of the autocomplete
title: the title of the autocomplete section for this suggester
subtitle: the subtitle / helper text of the autocomplete section for this suggester
Adding a new suggester - Configuration
Without the need to recompile Datafari or DatafariUI, you can add new suggesters in the autocomplete just by declaring them in the config file, as long as you do not want to declare a new type of suggester used in the backend (see the next chapter for adding a new type of suggester). You can get the list of currently implemented suggesters types by looking at this file: https://gitlab.datafari.com/datafari-community/DatafariUI/-/blob/dev/src/Components/SearchBar/Autocompletes/Suggester/useSuggesters.js
You also need to add the suggester into the file $DATAFARI_HOME/tomcat/conf/entity-autocomplete.properties see https://datafari.atlassian.net/wiki/spaces/DATAFARI/pages/2681831425/Adding+entity+autocomplete+from+indexation+to+autocomplete#Configuring-Datafari-to-Serve-the-New-Suggest-Request-Handler
In the configuration below, we have 3 suggesters : 1 of type basic and 2 of type entity. The difference between the 2 entities suggesters here, is at the field, the name of the request handler used and titles parameters level, but it could also be at the subtitle level.
Code Block | ||
---|---|---|
| ||
... "searchBar": { "suggesters": [ { "type": "BASIC", "props": { "maxSuggestion": 5, "title": "SUGGESTED QUERIES", "subtitle": "Queries extending your current query terms", }, }, { "type": "ENTITY", "props": { "field": "authorTokens", "suggester": "suggestAuthors", "typedictionary": "BASICsuggesterEntityAuthors", "propsasFacet": {false, "maxSuggestion": 5, "title": "SUGGESTEDEntities QUERIESsuggested", "subtitle": "Queries extending your current query terms", }, }, { "type": "ENTITY", "props": { "field": "authorTokensauthorSocialSecurityNumber", "suggester": "suggestAuthorssuggestSocialSecurityNumber", "dictionary": "suggesterEntityAuthorssuggesterEntitySocialSecurityNumbers", "asFacet": false, "maxSuggestion": 5, "title": "Entities suggested by social security number", "subtitle": "Queries extending your current query terms" } }, ] { } "type": "ENTITY", "props": { "field": "authorSocialSecurityNumber", "suggester": "suggestSocialSecurityNumber", "dictionary": "suggesterEntitySocialSecurityNumbers", "asFacet": false, "maxSuggestion": 5, "title": "Entities suggested by social security number", "subtitle": "Queries extending your current query terms" } } ] } ... |
Adding a new type of suggester
This requires developing new components in DatafariUI. Refer to the DatafariUI read me for more information on how to do that.
Define the list of prefered sources
You can define a list of prefered sources by adding a “sources” key to the ui-config object that holds an array of source names, ordered in decreasing order of their importance.
Code Block |
---|
{
...
"sources": ["source name 1", "source name 2"]
} |
If absent or empty, this has no effect. When present, results coming from the preffered sources are boosted and appear higher in the search results.
Warning |
---|
This feature is not active yet (as of April 2022). You can define you preferences, but no boosting will occur. |
MappingValues (optional)
From ui-config.json
file, you can customize labels from results list for each FieldFacet
or Field tab
. This field is a map key/value to rename a specific name.
Example:
Code Block | ||
---|---|---|
| ||
mappingValues: {
"pdf": "Fichier PDF",
"doc": "Fichier Doc"
"html": "Fichier Web"
} |
Key value is case sensitive, the label from label have to match exactly to rename the label (i.e. html
is different of HTML
)
QueryParams
From ui-config.json
file, you can customize the fields you send to Solr. queryParams
is an object which can have the following keys :
...
Key name
...
description
...
Default value
...
fields
...
An array of string that define fields sent to solr for each query.
...
Code Block | ||
---|---|---|
| ||
"fields": [
"title",
"url",
"id",
"extension",
"preview_content",
"last_modified",
"crawl_date",
"author",
"original_file_size",
"emptied",
"repo_source"
] |
useHotkey hook
This hook allows to define a hotkey with one command key plus an optional second letter key.
Command keys are defined as below (case sensitive) :
shift
alt
ctrl
escape
These command keys are defined in src/Hooks/useHotkey.js
. Use exported cmd keys ID in other components.
These command keys can be associated with another key like any alphanumeric key, to provide hotkey under the form : [CMD+key]
such as [ctrl+k]
, [shift+S]
etc.
useHotkey
hook can be used anywhere in the react application. Exemple of use :
Code Block |
---|
import { CTRL } from "src/Hooks/useHotkey.js"
const { hotkey: ctrlHotkey } = useHotkey({
cmd: CTRL,
key: "D",
enable: true,
callback: handleHotkey,
});
|
The hook uses the following parameters :
cmd
: Command key, one of defined command keys in the useHotkey js filekey
(optional, default value to "") : Second key of the hotkey.enable
(optional, default is false) : True to enable the hotkey. False otherwise. In this last case, empty string will be returnedcallback
: Called if command key matched and either the second key matched or it equals to empty string
The hook returns a component that represents the hotkey. You can mount it wherever you want in your component. By default, this component displays the hotkey between []
like [⇧S]
.
Hotkeys configuration
Hotkeys can be configured into ui-config.json
file, like below ;
Code Block | ||
---|---|---|
| ||
"hotkeys... |
Adding a new type of suggester
This requires developing new components in DatafariUI. Refer to the DatafariUI read me for more information on how to do that.
Define the list of prefered sources
You can define a list of prefered sources by adding a “sources” key to the ui-config object that holds an array of source names, ordered in decreasing order of their importance.
Code Block |
---|
{
...
"sources": ["source name 1", "source name 2"]
} |
If absent or empty, this has no effect. When present, results coming from the preffered sources are boosted and appear higher in the search results.
Warning |
---|
This feature is not active yet (as of April 2022). You can define you preferences, but no boosting will occur. |
MappingValues (optional)
From ui-config.json
file, you can customize labels from results list for each FieldFacet
or Field tab
. This field is a map key/value to rename a specific name.
Example:
Code Block | ||
---|---|---|
| ||
"mappingValues": {
"pdf": "Fichier PDF",
"doc": "Fichier Doc",
"html": "Fichier Web"
} |
Key value is case sensitive, the label from label have to match exactly to rename the label (i.e. html
is different of HTML
)
The mappingValues block is global, it does not belong to a facet block, so it must be declared at the same level than the queryParams block or the hotkeys block
QueryParams
From ui-config.json
file, you can customize the fields you send to Solr. queryParams
is an object which can have the following keys :
Key name | description | Default value | |||||
---|---|---|---|---|---|---|---|
fields | An array of string that define fields sent to solr for each query. |
|
useHotkey hook
This hook allows to define a hotkey with one command key plus an optional second letter key.
Command keys are defined as below (case sensitive) :
shift
alt
ctrl
escape
These command keys are defined in src/Hooks/useHotkey.js
. Use exported cmd keys ID in other components.
These command keys can be associated with another key like any alphanumeric key, to provide hotkey under the form : [CMD+key]
such as [ctrl+k]
, [shift+S]
etc.
useHotkey
hook can be used anywhere in the react application. Exemple of use :
Code Block |
---|
import { CTRL } from "src/Hooks/useHotkey.js"
const { hotkey: ctrlHotkey } = useHotkey({
cmd: CTRL,
key: "D",
enable: true,
callback: handleHotkey,
});
|
The hook uses the following parameters :
cmd
: Command key, one of defined command keys in the useHotkey js filekey
(optional, default value to "") : Second key of the hotkey.enable
(optional, default is false) : True to enable the hotkey. False otherwise. In this last case, empty string will be returnedcallback
: Called if command key matched and either the second key matched or it equals to empty string
The hook returns a component that represents the hotkey. You can mount it wherever you want in your component. By default, this component displays the hotkey between []
like [⇧S]
.
Hotkeys configuration
Hotkeys can be configured into ui-config.json
file, like below ;
Code Block | ||
---|---|---|
| ||
"hotkeys": {
"activeSearchBar": {
"cmd": "shift",
"key": "S",
"enable": false
},
"deactiveSearchBar": {
"cmd": "escape",
"enable": false
}
} |
Be care, cmd and key are case sensitive. If you use shift
as command, the key MUST be in CAPITAL.
Hotkeys IDs are defined into the useHotkey.js
(activeSearchBar
, deactiveSearchBar
, ...). Defined here other IDs to increase the list of hotkeys available
Export search results
In ui-config.json
, you can add some export format that the backend offer. So far (31.01.2023), Datafari API offers excel
format to export results list.
Code Block | ||
---|---|---|
| ||
"exportResults": { "activeSearchBarexcel": { "cmdminResults": "shift"1, "keymaxResults": "S"5000, "enabledefaultResults": false100 }, "deactiveSearchBar": { "cmd": "escape", "enable": false } } |
Be care, cmd and key are case sensitive. If you use shift
as command, the key MUST be in CAPITAL.
...
} |
exportResults
have to have at least one key under (here is Excel
. Each keys here will be a format in the export modal
:
...
Under each key, the following fields are mandatory:
minResults
: minimum number of results to be exportedmaxResults
: maximum number of results to be exporteddefaultResults
: default number of results to be exported
The key format is the type format defined in the backend (excel
for example)
DEV mode banner
In ui-config.json
, you can set the dev mode on. It can be useful for instance to warn your datafari users that you have not finished configuring your Datafari, but that they can start playing with it. In DatafariUI, a warn banner will be showed in the bottom of the screen. Here is a sample configuration :
...
You can decide which fields to display in the advanced search dropdown lists, and which labels to use. For that, please refer to Advanced search - Fixed values list for fields and labeled fieds /wiki/spaces/DATAFARI/pages/331415555
Customizing colors and theme
...