Variant
In the QSC console it is possible to configure the behaviour of variants.
- all variants are displayed in the search result as documents
- only the most recent variant is displayed in the search result
- the top n variants are returned as sub documents
Feeding
- feed every variant as a single document
- the variants are grouped by a variantFieldName, that contains a unique id for every variant
- every variant has the same id value
- variantFieldName must be a keyword field
- variants can be sorted by any indexed field - sometimes it is necessary to index a special field for sorting, e.g. a specified order in a CMS
Search Configuration
{
"variantId": "myVariantId",
"variantSort": "mySortField",
"variantSize": 10,
"variantResultField": "myResultField",
"variantCountField": "variantCount",
"mapping": [
{
"from": "product_name",
"to": "name"
},
{
"from": "product_price",
"to": "price"
}
],
"options": [
"replaceFirstVariant",
"fieldToList",
"groupChilds"
]
}
Property | Type | Description |
---|---|---|
variantId | string | Unique identifier for the variant configuration. |
variantSort | string | Name of the field used to sort the results within this variant. |
variantSize | integer | Maximum number of results to return for this variant. |
variantResultField | string | Field name to return the variants |
variantCountField | string | Field name to return the variant count |
mapping | array of DisplayMappingDTO | List of field mappings from the source result to display fields. |
options | array of string | Set of options that modify variant behavior. |
DisplayMappingDTO
Each element in the mapping
array defines how a field from the source data should be transformed or renamed.
Field | Type | Description |
---|---|---|
from | string | Original field name in the result. |
to | string | Target field name to display or map to. |
Options
Options modify how variants are processed. Possible values include (but are not limited to):
replaceFirstVariant
: Replaces the first variant in the list.groupField
: Transforms all variants to a list in the parent document. The fields are defined in the mapping.groupDocument
: The variants are grouped and returned as a subField. The mapping is used the specify the fields of the grouped documents.
Use cases
- if multiple variants are matching for search, the variant that is displayed is sorted by another sort criteria like the order in the CMS or Shop Backend
Search Configuration -- Deprecated --
For the configuration of variants in the search special variables are used.
Required parameters
- variantId: variantFieldName - the
Optional parameters:
- variantSourceGroupField - the field wich is displayed in the API
- variantSize - number of returned variants in the result
- variantSort - json string that defines how the variants are sorted
Example Configuration:
key | value | comment |
---|---|---|
variantId | myVariantId | myVariantId is a unique id that correlate all variantes |
variantSourceGroupField | productVariants | this can be a complex object - TODO support mulitple fields |
variantSize | 12 | how many variants are returned |
variantSort | [ { "variantSort": "desc" } ] | how the variantes are sorted - this can be any indexed field |
BETA: Variants based on multiple fields
This feature is just in beta. The configuration is done with variables at the moment.
- configure a mapComplexVariantId variable in Feeding
"variables": {
"mapComplexVariantId": "variantId,attr_herstellerfarbe_txt",
}
- configure the variantId in search:
"variables": [
{
"key": "variantId",
"value": "complexVariantId"
}
],
This feature is used in the https://shop-waldlaeufer.de/ shop.
To disable variants in a POST request:
{
"result": {
"facet": {
"enabled": false
}
}
}