Skip to main content

Implement Fuzzy Matching in Filters

Scenario: In e-commerce, product titles often include many high-frequency search terms for search optimization, which makes product title changes unpredictable. Maintaining a matching table of product short names based on product titles is tedious and impractical, so filtering by short name is not feasible. Therefore, the customer wants to filter products by specific flavor keywords in product names, that is, fuzzy matching, and wants to filter multiple flavors at the same time, meaning the relationship between flavors should be OR.

Effect:

image.png

Implementation:

1. Configure a global parameter: Admin Settings - Resource Management - Global Parameters - Create Parameter. As shown below, create a multi-value text parameter named Flavor. You can set options in advance, or modify options later from the parameter filter editing page. Note: A single-value parameter applies only to single-select filters, while a multi-value parameter is compatible with both single-select and multi-select scenarios. Therefore, we recommend creating a multi-value text parameter.

image.png

2. Enter the card editing area and configure the calculated fields needed in the filter area. Create a calculated field and reference the text parameter created in the previous step.

Note: In the card editing area, when adding a calculated field, split does not take effect on a text global parameter directly. You need to create a separate calculated field for the global parameter, and then apply split to that added calculated field. The field Flavor in the figure below is an example.

image.png

3. Continuing from the previous step, create a calculated field named Parameter Control and drag it into the filter area.

If the filter only needs single selection, use the instr function. The field type is Boolean.

instr([Product Title], [Flavor]) > 0

For multi-select filter scenarios, there are two SQL function writing methods. Choose either one. The field type is Boolean.

1)exists(split([Flavor], ','), x -> instr([Product Title], x) > 0)

2)array_sum(transform(split([Flavor], ','), x -> instr([Product Title], x))) > 0

image.png

4. Save the card editing and return to the dashboard page. Create a parameter filter on the page and select the parameter created in Step 1. The default value can be reselected, and optional values can be manually modified or imported from a dataset. The parameter filter automatically matches cards on the current page that use this parameter and links them automatically. The setup is complete.

image.png