Extending Category searches in Elasticsearch
To enhance relevance of search results, you can use the /configuration REST endpoint to change or extend the level of the category tree that is included in the category search.
Category searching with Elasticsearch
CATEGORY=natural.categories.normalized, natural.categories.[catalogId].raw, natural.nouns.raw, natural.categories.[catalogId].normalized
Changing the scope of the category search
Optionally, to enable the category search enable the category search with a full path of the category, then replace natural.categories.normalized, natural.categories.[catalogId].raw with natural.path_name.[catalogId].normalized
To enable category search, this field can be updated or the previous fields using /configuration endpoint as below with the PATCH or POST request methods.
PATCH/POST - http://<dataQueryHost>:<dataQueryPort>/search/resources/api/v2/configuration?nodeName=component&envType=auth
{
"extendedconfiguration": {
"configgrouping": [
{
"name": "SearchConfiguration",
"property": [
{
"name": "nlp.classification.field.mapping",
"value": "NOUN=natural.categories.[catalogId].normalized#natural.nouns.raw,CATEGORY=natural.path_name.[catalogId].normalized#natural.nouns.raw#natural.categories.[catalogId].normalized,BRAND_NAME=natural.names.normalized#natural.names.raw,ADJECTIVES=natural.adjectives.normalized#natural.adjectives.raw#natural.nouns.raw#natural.categories.[catalogId].normalized,ADJECTIVES_NAME=attribute.name.normalized#attribute.name.raw#natural.nouns.raw#natural.categories.[catalogId].normalized,UNIT_OF_MEASURE_DEFAULT_FIELD=attribute.value.raw#natural.nouns.raw#natural.categories.[catalogId].normalized,STA_QUERY_FIELD=natural.categories.[catalogId].normalized#natural.nouns.raw,ROOT_BOOSTING_FIELD=nlp.name.normalized#nlp.keyword.text"
}
]
}
]
}
}
- If this is the first time if you are adding the configuration through the /configuration endpoint, then use the POST request method. Otherwise use the PATCH request method.
- Before updating the field, ensure that the field natural.path_name.[catalogId].normalized is updated. If the field is not there, do a full reindex to add the field to the product index.
- After adding or updating the configuration, restart the Query service.
Enabling category search for non-leaf categories
HCL Commerce allows Shoppers to find products based on their associated parent category name, orin the case of a list of category names. This situation can arise when linked categories or a full category path search are enabled for searching. Once a category name match is found, all products within this category are returned in the search result. Additional refinement can be performed together with other terms in the same search phrase. For example, a search phrase "Gusso dresses" includes a Gusso brand name and a category name (as well as a product name) called "dresses". This search will return all products under those categories that have "dresses" in their name that are of the Gusso brand, followed by other products that only match "Gusso" or "dresses" in their name or short description.
Category search is disabled in Basic NLP. This means that while
performing keyword searches, only leaf level categories are considered when matching
the input term to categories. You can configure the system to match the input term
for non leaf categories as well, using the following configuration endpoint. Set the
value of the Ingest property flow.basic.nlp.category.search to
true
. By default category search is disabled; to enable it,
perform the following steps.
- Execute a PATCH request to the Ingest configuration API with the included
request
body.
PATCH - http://dataQueryHost:dataQueryPort/search/resources/api/v2/configuration?nodeName=ingest&envType=auth { "global": { "connector": [ { "name": "attribute", "property": [ { "name": "flow.basic.nlp.category.search", "value": "true" } ] } ] } }
- Perform a full reindex. See Building the Elasticsearch index for the procedure.
- Restart the Query service. For more information, see Starting the Query Docker container with default configurations.