Navigating the search term with searchExecution
Search expression providers are designed process the input of the search term. To
help you gain a deeper understanding of how these providers function, the details of the
fields under the searchExecution
are analyzed to show how they contribute
to fetching results based on the input search term.
Search expression providers
The following examples use the searchExecution
data under the
metaData
in the response JSON string. Within this metadata,
each field holds a distinct purpose in enhancing the accuracy and relevance of your
search results.
The examples use the HCL Commerce Search REST API. For more information, see REST API for Elasticsearch-based Search.
Spell Correct
The Spell Correct provider utilizes the Elasticsearch suggest API to correct search
term spellings. By comparing search term with product index, it identifies potential
spelling errors and suggests the most appropriate corrections. For example, if you
search for "blck dress," the SpellCorrect
provider recognizes your
intent and suggests "black dress" as the corrected term.
GET http://hostname:port/search/resources/api/v2/products?storeId=11&searchTerm=blck dress
Response Metadata:
"metaData": {
...
"spellcheck": [
"black",
"blue",
"blank"
],
"searchExecution": [
{
"searchTerm": "blck dress",
"spellCorrect": "blck dress --> black dress",
"searchRule": {},
"nlp": {
"pos": "ADJECTIVE --> [black]",
"ner": "CATEGORY --> [dress]",
"color": "COLOR --> [black]"
},
"customFields": {}
}
]
}
For more information on customizing the spell check function, see Customizing spell check correction suggestions.Stopword
The Stopword
provider takes on the responsibility of eliminating
stopwords from your search terms. Stopwords are common words (for example, "the", "and",
"by", "is") that do not contribute significantly to deducing the intent of the search. By
removing them, this provider enhances the relevance of your results. The Stopword
terms are contained in a list configured via Zookeeper. The provider also leverages
the IGNORE_TERM Named Entity Recognition
(NER) method to further
identify and eliminate stopwords from your search query.
GET http://hostname:port/search/resources/api/v2/products?storeId=11&searchTerm=party dress by Albini
Response Metadata:
"metaData": {
...
"searchExecution": [
{
"searchTerm": "party dress by Albini",
"stopword": "[by] --> party dress albini",
"searchRule": {},
"nlp": {
"pos": "NOUN --> [parti~party] | ADJECTIVE --> [albini]",
"ner": "CATEGORY --> [dress]"
},
"customFields": {}
}
]
}
Search Term Association (STA)
SearchTermAssociation
(STA) provider is responsible for parsing
your search term and applying modifications based on the STA configuration in
the Management Center. It plays a pivotal role in customizing your search query to
enhance your search results. It operates in two primary ways:- Synonyms
- When synonyms are identified in your search term, the STA provider adds additional terms to broaden the scope of your search. For example, if you search for "couch" the STA provider might expand your search to include "sofa" ensuring you don't miss relevant results.
- Replacements
- In cases where specific terms are identified for replacement in your search term, the STA provider makes these substitutions. For instance, if you search for "desk" but there is a configuration to replace "desk" with "table," the STA provider ensures that your search reflects this replacement.
Search Rule
searchExecution
metadata supports
several SearchRule
types, including Order,
Filter, Boost, and Replace
Term. Each type of rule leads to the addition of specific query
sections in Elasticsearch to further customize the search.SearchRule
metadata supports rules of the types Change Search Result Order
and Add or Replace Search Criteria
with the
Property
type only. Other rule types are not supported at
this time.For more information, see Managing search rules.
- Filter
- If a Search Rule with a filter is identified, it adds the filters to the
query, refining the results to meet specific criteria such as
Name, Manufacturer Name,
Short Description, and so on. In this metadata, filters
with exclusions are denoted with
EXCL
and filters with inclusions are denoted withINCL
. For example,Name --> EXCL:[dinning, chair]
denotes a filter whereName
does not contain any of these values[dining, chair]
. - Order
- If a Search Rule pertaining to orders is identified as applying to the query, the provider adjusts the query to sort the search results in a particular order, such as by price, Manufacturer Name, or Name, and so on.
- Boost
- If a Search Rule with Promote or Demote is identified, the provider adjusts the query to enhance the relevance of specific results, such as Manufacturer Name, Name, etc.
- Replace Term
- If a Search Rule with search term replacement is identified, the provider substitutes the matching term with a designated replacement term in the query.
Part Number
The Part Number provider parses your search term and identifies part number patterns. If it detects a match, it initiates specific queries to the SKU and Manufacturer Part Number fields in the product index.
GET http://hostname:port/search/resources/api/v2/products?storeId=11&searchTerm=lr-fntr-0005
Response Metadata:
"metaData": {
...
"searchExecution": [
{
"searchTerm": "lr-fntr-0005",
"partNumber": "lr-fntr-0005 --> [lr fntr 0005]",
"searchRule": {},
"nlp": {},
"customFields": {}
}
]
}