Recipe: Skip the /e/oneVariant Snippet in Fixed Facets

Note:
This recipe applies to all SPARQUE API Wrapper versions.

Problem

In the standard product search flow, the SPARQUE endpoint chain applies /e/oneVariant before fixed facet snippets. This works correctly when fixed facets filter on product attributes, but causes incorrect results when a fixed facet (e.g., hotdeal) does not rely solely on product attributes—because relevant variants may already be removed before the facet is evaluated. This is, for example, the case when the filter is based on a relation or predicate between external data and product SKUs.

Solution

To solve this, an optional attribute addOneVariantSnippet has been added to fixed facet definitions. It defaults to true (no behavior change). When set to false for a specific fixed facet, the /e/oneVariant snippet is omitted from the SPARQUE call as computed by the Wrapper, and the variant selection logic must be handled within the fixed facet strategy instead.

Discussion

To configure the addOneVariantSnippet for a fixed facet, follow these steps:

  1. Add the addOneVariantSnippet attribute to the fixed facet option in the fixed facet XML definition:

    <?xml version="1.0" encoding="UTF-8"?>
    <Fixedfacets>
      <option>
        <channel>ish</channel>
        <name>hotdeal</name>
        <attribute>
          <name>addOneVariantSnippet</name>
          <value>false</value>
        </attribute>
        ...
  2. Add the following mapping in the SPARQUE configuration so that SPARQUE can read the new attribute:

     <spinque:attribute
         subject="{$optionId}"
         attribute="addOneVariantSnippet"
         type="string"
         value="{attribute[name='addOneVariantSnippet']/value}" />
  3. To expose the attribute in the SPARQUE result description, add the following entry to the attributes array of the fixed facet result description:

    JSON example:

    {
      "class": "https://www.sparque.ai/fixedfacet",
      "level": 1,
      "mode": "full",
      "attributes": [
        {
          "name": "identifier",
          "type": "STRING",
          "aggr": "most_frequent",
          "splitLanguages": true
        },
        {
          "name": "title",
          "type": "STRING",
          "aggr": "most_frequent",
          "splitLanguages": true
        },
        {
          "name": "displayname",
          "type": "STRING",
          "aggr": "most_frequent"
        },
        {
          "name": "displayType",
          "type": "STRING",
          "aggr": "most_frequent",
          "splitLanguages": true
        },
        {
          "name": "selectionType",
          "type": "STRING",
          "aggr": "most_frequent",
          "splitLanguages": true
        },
        {
          "name": "limitCount",
          "type": "INTEGER",
          "aggr": "most_frequent"
        },
        {
          "name": "minCount",
          "type": "INTEGER",
          "aggr": "most_frequent"
        },
        {
          "name": "position",
          "type": "INTEGER",
          "aggr": "most_frequent"
        },
        {
          "name": "addOneVariantSnippet",
          "type": "STRING",
          "aggr": "most_frequent"
        }
      ],
      "constants": [],
      "includes": []
    }

Behavior

addOneVariantSnippet valueSPARQUE call
missing or true/e/search/e/oneVariant/e/hotdeal/results (standard behavior)
false/e/search/e/hotdeal/results (oneVariant removed)