Customizing Search Results
Fundamentally RVS is built for searching multiple groups within one search.
These groups search for results with their own queries and their behavior can be
modified individually. On the initial view of the search results, you see all
the groups, their titles, the number of search results in the group and the most
relevant search results per group. Each groups search results can be accessed
through more search results
link, and all of the search results for the group
can be browsed in the individual group details view.
On top of the modifying group behaviour you can change search results appearance
and the data shown on a global level and on group level. i.e. remove date from
group PDF files
-group. This can be done with slot overrides
.
Default behavior
Search results are limited to the language of the webpage. Search on a english page yields english results and search on a finnish page yields finnish results.
Without any customization, RVS forms one group where it searches from all
documents in the index. The results are shown in the order of their relevancy.
Five most relevant search results are shown on the front page of the search and
more can be seen after clicking more search results
button.
If you have configured more than one search result group, groups are ordered by the relevancy of their best result. This behavior can be customized, see //XXX group ordering linkki
Defining groups
You can define multiple groups in the ValuSearch
constructor. For groups to
differentiate in a meaningful way you need queryable tags
. Groups type:
Minimal groups example:
const vs = new ValuSearch({
customer: "<customer id>",
apiKey: "<api key>",
groups: [
{
title: "Group1",
filters: {
tagQuery: [["group1-tag"]],
},
},
{
title: "Group2",
filters: {
tagQuery: [["group2-tag"]],
},
},
],
});
The group interface is following
interface GroupOptions {
/**
* Identifying group id. This is shown as a query param when navigated to group view
* By default this is group index in groups[]
**/
tagGroupId?: string;
/**
* Title shown in the UI
**/
title: string;
/**
* Used in conjunction with `orderBy: "score"`
* Demoting and promoting groups. >1 values promote content, <1 demote content.
**/
scoreBoost?: number;
filters: {
/**
* Queries search results that match the tag query
* [[tagA, tagB]] tagA OR tagB
* [[tagA], [tagB]] tagA AND tagB
*/
tagQuery: string[][];
/**
* 0-1 numerical value for demoting old pages
*/
createdDecay?: number;
/**
* 0-1 numerical value for demoting stagnant pages
*/
modifiedDecay?: number;
/**
* String type time expression
* Used with createdDecay or modifiedDecay
* Defines in which timeframe decay filter is applied, e.g. "7d"
*/
decayScale?: string;
/**
* Defines highlight length
* Use 0 for blocking highlight query (performance boost)
*/
highlightLength?: number;
};
}
tagQueries
We support AND and OR logical operators.
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.
i.e. 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
matching tag to their name and querying it
swimming OR biking OR ... OR sport100
, give each sport page sport
tag and
use it in the query.
Decay filters
If your website exposes created and modified timestamps for pages these can be used with group decay filters.
You can use either createdDecay
or modifiedDecay
. Created decay demotes old
pages, modified decay demotes stagnant pages. Number should be smaller than 1.
Example, "Pages that were created a week ago are half as relevant":
createdDecay: 0.5,
decayScale: "7d"
If decayScale
is not defined, the default is 365d
. We use an exponential
curve filter; results on the lower end of the curve approach zero.
Group ordering
Group ordering can be done by passing orderBy
option to VS constructor.
const vs = new ValuSearch({
...
orderBy: "score",
...
We support following options for organizing search result groups:
score (default)
Groups are ordered by their best search results. If two groups best result have the same relevancy, original order of those groups is kept.
original
Original order passed is not changed.
originalNotEmpties
Original order is kept, but if a group had no results in it, it is shown last. If multiple groups are empty they are shown last in their original order.
tagName
Groups are ordered alphabetically by their titles. Note groups can have different titles in different language version --> different order between languages.
total
Groups are ordered by the number of their search results. If two groups have the same amount of results, original order of those groups is kept.
Modifying the search result entry
See Hit
slot // XXX link here