Skip to main content

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"
]
}
PropertyTypeDescription
variantIdstringUnique identifier for the variant configuration.
variantSortstringName of the field used to sort the results within this variant.
variantSizeintegerMaximum number of results to return for this variant.
variantResultFieldstringField name to return the variants
variantCountFieldstringField name to return the variant count
mappingarray of DisplayMappingDTOList of field mappings from the source result to display fields.
optionsarray of stringSet 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.

FieldTypeDescription
fromstringOriginal field name in the result.
tostringTarget 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:

keyvaluecomment
variantIdmyVariantIdmyVariantId is a unique id that correlate all variantes
variantSourceGroupFieldproductVariantsthis can be a complex object - TODO support mulitple fields
variantSize12how 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
}
}
}