Configure how search analytics are stored. If you want to disable analytics, set this to false
.
Optional
aggregationThe "debounce" time used in aggregating searches, so that e.g. typing
i, ip, ipa, ipad (delay)
will only result in "ipad" being logged (when logAnalytics: true
is set).
This is to avoid logging searches for terms that the user is still typing.
The AnalyticsStrategy determines how search analytics are stored and retrieved for analysis.
Optional
bufferIf set to true, updates to Products, ProductVariants and Collections will not immediately trigger an update to the search index. Instead, all these changes will be buffered and will only be run via a call to the runPendingSearchIndexUpdates mutation in the Admin API.
This is very useful for installations with a large number of ProductVariants and/or Collections, as the buffering allows better control over when these expensive jobs are run, and also performs optimizations to minimize the amount of work that needs to be performed by the worker.
Optional
collectionAn optional prefix string for the Typesense collections that will be created. This can be useful if you are running multiple Vendure instances which share the same Typesense instance, as it allows you to differentiate between the collections created by each instance.
Optional
customCustom mappings allow you to define additional fields which will be indexed in the products index.
AdvancedSearchPlugin.init({
// ...
customMappings: {
reviewRating: {
graphQlType: 'Float',
valueFn: ({ variant }) => variant.product.customFields.reviewRating,
},
reviewCount: {
graphQlType: 'Int!',
valueFn: ({ variant }) => variant.product.customFields.reviewCount,
},
facetValues: {
graphQlType: 'String!',
searchable: true,
hydrateRelations: ['product.facetValues'],
valueFn: ({ variant, languageCode }) =>
variant.product.facetValues
.map((fv) => translateDeep(fv, languageCode).name)
.join(' '),
},
featuredAssetName: {
graphQlType: 'String!',
hydrateRelations: ['product.featuredAsset'],
valueFn: ({ variant }) => variant.product.featuredAsset?.name ?? '',
searchable: true,
},
discountPercentage: {
graphQlType: 'Float',
valueFn: ({ variant }) => variant.customFields?.discountPercentage,
outputFn: (values: number[], groupByProduct: boolean) => {
if (groupByProduct) {
return Math.max(...values);
} else {
return values[0];
}
},
},
},
}),
Optional
documentIt is possible to override the indexed value of the built-in fields on the SearchResult
type.
For example, let's say you have a customField which stores a "sale price" which you want
to use in your search results. Here's how you can configure it:
Optional
externalAllows you to define additional external indexes which can be queried alongside the main product index.
Optional
internalWhen searching the product index, data on related Collections and Facets is cached for performance reasons. This setting allows you to set the TTL (how long a cached item lives before it must be refreshed from the database) for this cache.
A higher value will reduce the number of database queries made during search, but may result in stale data being returned.
The license key can be found in your Vendure Hub account at https://vendure.io/account/licenses, and then clicking on the installation instructions for this plugin's license
Optional
shopA secret string used to encrypt the Shop API key in the database. When this is set, a new customField will be defined on the GlobalSettings entity, which is used to store the encrypted shop API key.
Optional
sortableAllows you to define additional ways to sort the search results.
AdvancedSearchPlugin.init({
// ...
sortableFields: [
// Here we are specifying that the 'sku' field
// should also be sortable
{ name: 'sku' },
// Assuming we have defined a customMapping for reviewRating
// (as in the example above), we can also make this sortable.
{
// This name must match the field name internally in TypeSense,
// which, for customMappings is always of the format
// `customMapping_<name>`.
name: 'customMapping_reviewRating',
// We can alias this with a more friendly name that will be used
// in the GraphQL API "sort" input.
alias: 'rating'
}
],
});
The configuration options for the Typesense client.
The plugin can be configured using the following options: