Search Params
The search request can be customized with the params
option
const ui = new FindkitUI({
publicToken: "<TOKEN>",
params: {
// Limit results to example.com domain
tagQuery: [["domain/example.com"]],
},
});
The params can be dynamically updated using the
ui.updateParams()
method and the
useParams()
hook
to update from Slot Overrides.
Options
api docscreatedDecay: number
0-1 numerical value for demoting old pages
modifiedDecay: number
0-1 numerical value for demoting stagnant pages
decayScale: string
To be used with createdDecay
or modifiedDecay
. Defines in which timeframe
decay filter is applied, e.g. "7d".
highlightLength: number
The length of returned hilight string. Se to 0
disable highlighting.
Too large values might slow down the search.
size: number
How many results to fetch in a single request.
lang: string
Limit results to the given language. A two letter language code. Not to be
confused with the lang
constructor option which sets the UI
language.
tagQuery: string[][]
Filter results using tags. For more flexible filtering based on your custom
fields see filter
.
Logical AND and OR operators are supported.
OR-syntax:
[["A", "B", "C"]]; // A OR B OR C
AND-syntax:
[["A"], ["B"], ["C"]]; // A AND B AND C
combining queries:
[["A"], ["B", "C"]]; // A AND (B OR C)
Complex tag queries can be expensive. Because of this, it's recommended that you preprocess your pages to have meaningful tags.
For example if there is 100 different sports categories on your website and you want to
show all the search results in a group "Sports". Instead of giving each sport a
specific tag name and querying it swimming OR biking OR ...
give each sport page a sport
tag and use it in the query.
tagBoost: Record<string, number>
Boost page scores with certain tags.
Example
const ui = new FindkitUI({
publicToken: "<TOKEN>",
params: {
tagBoost: {
important: 2,
},
},
});
This will increase the search score of pages with important
tag by x2. It is
also possible to down boost by using boost numbers less than one. Ex. 0.5 to
drop the score to half.
sort: Sort
New in v0.9.0
Use alternative sorting. By default search results are sorted by the relevancy score but it can be forced to be sorted by created or modified dates or by any custom field.
Example
const ui = new FindkitUI({
publicToken: "<TOKEN>",
params: {
sort: {
created: {
$order: "asc",
},
},
},
});
Multi-level sorting is also possible
const ui = new FindkitUI({
publicToken: "<TOKEN>",
params: {
sort: [
{
price: {
$order: "asc",
},
},
{
created: {
$order: "asc",
},
},
],
},
});
If sorting values are the same, the search results are sorted by the relevance score.
api docsfilter: Filter
New in v0.9.0
Filter the search results by tags, created, modified, language and custom field using a MongoDB style filtering query. Read more on the Filtering page.
api docsskip: boolean
New in v0.15.0
Skip the search and always return an empty response. Can be used to optimize the search request when visually hiding some of the groups.