Query Service

The Query service builds the search expressions and then hands the expression to Elasticsearch. It also takes the query results and translates them back into a form that can be used by the storefront. The storefront does not need to know that the response was generated by Elasticsearch rather than Solr.

In HCL Commerce Search Version 9.1, search queries are built using the Query microservice. It is used to create the search queries that will be passed to the Elasticsearch engine. The query-building function was built into the Search Docker container in previous versions of HCL Commerce, but as a separate microservice is now easier to address and customize.

Controlling Query using REST

The Query and Ingest services are the only APIs that are visible from outside the gateway. The service exposes its own REST end points, as described in the Query service API specifications.

All these heuristics are applied in building the search query, which is then passed on to Elasticsearch.

The query service consists of REST-enabled Java classes implemented as Spring Boot controllers. Spring Boot is an open source Java-based framework for creating micro-services. The annotated classes that it exposes by default are:
  • The Product view,
  • Category view, and
  • Content view.
You can add your own custom endpoint by adding new annotated Java classes. This approach makes it unnecessary for you to modify deployment descriptor or property files.

All configurations, including search profile, runtime configurations, and cache invalidation, can be set up via the REST API, and are stored in ZooKeeper. You can use inheritance and value overrides when configuring your Search profiles. Any custom logic referenced by search profiles can be implemented and shipped in Java class files, packaged and rebuilt into a custom docker image

To review the API, see the Query REST API.

Natural Language Processor

In addition to the text search and browse capabilities provided by the Query service, a natural language parser is integrated into the Query service to improve search relevancy. The natural language parser uses CoreNLP for part-of-speech tagging and lemmatization. The HCL Commerce Search Query service also provides the following additional features when analyzing the search phrase that is used by a shopper:
  • Natural language parsing with CoreNLP part-of-speech tagging, named entity extraction – nouns and names against brand and product names, and adjectives against attribute values
  • Matchmaker for color name mapper, measurement, and dimension range mapper to identify attribute values in close proximity.
  • Measurement conversion for length, weight, volume, date and time.
  • Range filter that can identify a range condition in a given search phrase and map that into a range filter for search.
The query builder can recognize common attributes of a product, such as color and dimension, even if these are expressed in reasonable colloquial language For example, the service can correctly parse a search string such as ​"I am looking for a pair of white dress shoes," doing the following with it:
  • Identifying the intent of the statement as "Buy."
  • Doing name-entity-extraction using a custom dictionary (added through previous training) to identify "dress shoes" as a noun.
  • Using "dress shoes" the noun to search against the Product Name catalog field.
  • Identifying the part-of-speech "white" as an adjective and using it to search against Attribute catalog fields.
  • Identifying the value "white" as a color name and normalizing it to the RGB code FFFFFF. "Light" colors can be normalized to anything with an RGB code greater than A0A0A0.
  • At index time, normalizing the color name "cream" to a primary color family RGB code FFFFFF.
  • Via text classification, identifying "dress shoes" (through a custom dictionary) is of "shoes" category and an additional filter with category name containing "shoe" (lemmatized).
In the case of dimensions, the service can parse the search string ​"find me a 6 foot TV" and correctly recognize that "6 foot" is an adjective, using it to search against Attribute fields in the catalog. In this case, the value "foot" is identified as a dimension name and its value will be converted if necessary into other supported length measurements, such as "inches", "cm", "meter."

For more information, see Text Relevance in HCL Commerce Search and .Natural Language Processing (NLP) in Version 9.1