This article explains how to use fuzzy search with query analysis, including when to use intervention dictionaries and the required search syntax.
When to use fuzzy search with query analysis
In some cases, using only a fuzzy search analyzer is insufficient or may return poor results. In these situations, use query analysis to optimize the outcome. However, fuzzy search is designed to broaden recall by finding inexact matches, and query analysis cannot be configured for indexes on SHORT_TEXT type fields. You can work around this limitation by creating multiple fields with different data types and configuring indexes with different analyzers. The following procedure demonstrates this workaround.
Note:
-
The stopword feature of query analysis does not apply in this scenario.
Procedure
-
On the Instance Management page, find your application and click Details. Then, click Offline Change to open the Application Change page.
-
Add the fields you want to query. Set the
brandfield to theSHORT_TEXTtype and thebrand_textfield to theTEXTtype. Both fields will map to thebrandfield from the data source. Click Next. You will configure the application structure, which is the first of three steps that also include index structure and data source.
3. On the index structure configuration page, add a brand index for the brand field and select Fuzzy Analyzer as the analyzer. Then, add a brand_text index for the brand_text field and select Chinese - General Analysis as the analyzer. Click Next.
4. On the data source configuration page, click Edit. Configure the field mappings. Ensure both the brand and brand_text fields map to the brand field in the data source, and then configure the mappings for all other newly added fields. Click Completed. 5. Wait for the offline version to be created. When its status changes to Normal, you can configure query analysis. In the left-side navigation pane, go to Search Algorithm Center > Retrieval Configuration > Query Analysis. On the Query Analysis page, click Create in the upper-right corner.
6. Configure the query analysis rule: For the feature, select synonym and choose a synonym intervention dictionary. Set the rule name to brand_qp, the index scope to brand_text, the industry type to General, and the Query rewrite strategy to AND. Under dictionary usage, select system built-in dictionary and for the intervention dictionary, select the synonym dictionary you created. Click OK. 7. To test the configuration, add a synonym intervention entry. Go to the Dictionary Management page and click Add Intervention Entry. Set the Query to soso and the synonym to search. After you save the entry, its status becomes Active. 8. Compare the test results:
query:brand_text:'soso' OR brand:'soso'
Without the brand_qp query analysis parameter: On the Search Test page, the query returns 0 results.
With the brand_qp query analysis parameter: The search returns 2 results. Synonym mapping expands the query term, mapping soso to search. This retrieves records where the brand field value is search or search engine, which confirms that the synonym intervention is effective.