Elasticsearch v7 - Dimensional Analyzer and Fractional Number Search

  • Updated

In Elasticsearch version 7, you can use the Dimensional Analyzer to search products by product size with search terms containing the size and unit of measurement. The Dimensional Analyzer also supports searching product sizes with search terms containing fractional number sizes.

Configure the Dimensional Analyzer

  1. Identify the product attribute or the custom product property with the product size information.
  2. Go to Admin Console > Marketing > Search > Field Boosting.
  3. Select and edit the product size attribute or custom property.
  4. Toggle Queryable to Yes.
  5. Select Text for the Data Type.
  6. Select IscDimensionalAnalyzer as for Index Analyzer and Query Analyzer.
  7. Keep default Boost Value of 1 or increase the Boost Value to boost search results relevancy when searching by size.
  8. Click Save.



Product size data and search terms

Populate the Product Size field or attribute with the size and unit of measurement data that can indexed and queried. Some examples of products sizes and search terms that match the product size are listed in the table below. You or your partner can find a full list of supported standard fractions and measurement units and their equivalent mapped synonyms that can be used in search terms in the Configured Commerce code under the Insite.Search.ElasticsearchV7.TokenFilters namespace with names IscDimensionalTokenFilter and IscFractionalTokenFilter.

Product Size Search Terms
1/2 in 1/2 in, 0.5in, 0.5", .5", 1/2 inch, 1/2 inches
1 1/2 ft 1-1/2 ft, 1 1/2ft, 1.5ft, 1.5', 1-1/2 feet
1/4 oz 1/4 oz, 1/4 ounce, 0.25 oz, .25ounces
2.25 gallon 2-1/4 gal, 2.25gallons
1/32 quart 1/32 qt, 0.0313 quarts, 0.031qt, 0.03qt
27/32 cm 27/32cm, 0.8438 cm, 0.844cm, 0.84 centimeter

Rebuild search index

Once you have updated the product size information, go to Admin Console > Marketing > Search > Indexing. Click Rebuild All, and wait until search indexing is complete.


Example 1

Below is an example of a product. Dart Cafe G Design Cup is from the product category of Cups with size information of 0.75 oz in the product attribute Capacity. This product can be found using any of these search terms – 0.75oz, .75oz, 0.75ounce, 0.75 ounces, 3/4 ounce, 3/4oz, and so on.

Elasticsearch 1.png

Example 2

Below is an example of a product. Lion Insta-Cover Ring Easel Binder is from product category of Binders with size information of 2.50" in the product attribute Binder Capacity. This product can be found using any of these search terms – 2.5in, 2.50inches, 2-1/2inches, 2 1/2 inches, 2.5 inch, 2.5", and so on.

Elasticsearch 2.png

All product attributes are also stored together on the Search Index and queried using the Filters field, which uses the default analyzer. For a product attribute, the search query not only uses Dimensional Analyzer on the attribute but also uses the Default Analyzer on the Filters field. This may result in more text matches. Alternatively, to get more precise size matches, you can store product size information on a Custom Product Property and apply the Dimensional Analyzer to it.