Pairing Rules

Grouping products based on certain criteria for Multi Search API (Complementary / Outfit recommendations)

Selectively grouping products in the search results, if both the user's input & product's meta data matches the criteria stated in the parameter pairing_rules.

There are a few reserved keywords that is used in the JSON expression for user's input or product's data comparison.

Data structureDescription
conditions

List of expressions to determine if this search request should be grouped for some products

Grouping will be triggered if at least one of the input matches the criteria.

If you want this grouping to be triggered for all search request, then set the conditions as conditions:["true"]

groups

List of actions to determine the order of the group.

The list of actions has a list of expressions to determine which product should be part of the group.

The product will be part of the group if at least one of the criteria matches

📘

Evaluating expression of input/product with partial data

If the data that is meant to replace the keywords is missing, the entire expression will be considered as false.

Scenario:

  • Given that the product has data of brand="rezolve" and sub_brand=null

Bad example:

  • Given that expression is product.data.brand == "rezolve" || product.data.sub_brand == "multisearch"
  • This expression would still be considered as false

Recommended example:

  • Rewriting by breaking the expression to a list
    • product.data.brand == "rezolve"
    • product.data.sub_brand == "multisearch"
  • This will help the system to evaluate the expression in chunks where only 1 of it needs to be true

Example request

curl 'https://multimodal.search.rezolve.com/v1/product/multisearch/complementary?placement_id=xxx&app_key=xxx&q=xxx' \
--form 'pairing_rules="[
    {
        \"conditions\":
        [
            \"input.image_category == \\\"bracelet\\\"\",
            \"input.text_query == \\\"dress\\\"\"
        ],
        \"groups\":
        [
            {
                \"actions\":
                [
                    \"product.data.price.value >= 100 && product.data.price.value <= 200\",
                    \"input.image_category == \\\"necklace\\\"\"
                ]
            },
            {
                \"actions\":
                [
                    \"input.image_category == \\\"ring\\\"\"
                ]
            }
        ]
    }
]"'