Enable boosting on an attribute dictionary attributes for term searching

To enable searching and boosting on specific attribute dictionary attributes, follow the below steps.

Procedure

  1. Mark the ad attribute as merchandisable from the Management Center attribute dictionary attributes. This ID will be used later to configure a new Search-related setting.
  2. Add the boost factor in the index_field_relevancy Zookeeper node. This boost factor will influence the relevancy score.
    Use configuration API to add the boost field.
    PATCH - http://<dataQueryHost>:<port>/search/resources/api/v2/configuration?nodeName=index_field_relevancy&envType=auth
    Request Body:
    {
    	"filters.<ID>.text_*": "500"
    }
    
    ID must be replaced with the actual ID of the merchandisable attribute. * will be replaced at runtime with the supported locale.
  3. Trigger full reindex. This will populate all merchandising attribute values in the filters field. Then, the NLP Service will read the merchandising attribute ID configured in the Zookeeper node in step 2 and perform stemming on that specific attribute to handle singular v/s plural.
  4. Override the search profile to add filters.<ID>.text_* in the query field of the search profile through profiles API like below. ID must be the merchandisable attribute ID on which search and boosting need to be performed. * will be replaced at runtime with the current locale for the request.
    …
    "queryFields": [
                "default.search.text",
                "default.search.normalized",
                "default.search.text_*",
                "default.search.split",
                "filters.7000000000000000005.text_*"
            ]
      …
    
  5. Restart the query service.
  6. After this change, when searching with any keyword that matches the merchandising attribute value (including partial matches), those products will get boosted and expected to be at the top of the search result. The score of the matching document will be calculated based on the boost factor in the Zookeeper index_field_relevancy node for the merchandising attribute.
    The query will be generated as following:
    ….
    	{
                                        "query_string": {
                                            "query": "(\"synthet\")",
                                            "fields": [
                                                "default.search.normalized^1.0",
                                                "default.search.split^1.0",
                                                "default.search.text^1.0",
                                                "default.search.text_en_US^1.0",
                                                "default.sku.normalized^1.0",
                                                "filters.7000000000000000005.text_en_US^500.0",
                                                "natural.adjectives.normalized^20.0",
                                                "natural.keywords.normalized^100.0",
                                                "natural.nouns.normalized^100.0"
                                            ],
                                            "type": "most_fields",
                                            "default_operator": "and",
    	….
    
    Note: After this configuration change, even if the attribute is not marked as searchable, the configured merchandisable attribute will be used for searching.