Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fuzzy and proximity search together in Azure search

Need help with the query to combine proximity search and fuzzy search in Azure. Index has items below:

  1. University of Washington
  2. University of Mary Washington Foundation
  3. Washington Adventist University

Search term: Universty of Washington - (University misspelled)

This should return record 1. i.e Fuzzy matching on University and Proximity match on rest of the words.

like image 425
PumaPanama Avatar asked Sep 14 '25 00:09

PumaPanama


1 Answers

From the Azure Search documentation:

Fuzzy Search

To do a fuzzy search, use the tilde "~" symbol at the end of a single word with an optional parameter, a number between 0 and 2 (default), that specifies the edit distance. For example, "blue~" or "blue~1" would return "blue", "blues", and "glue".

Proximity Search

Insert a tilde "~" symbol at the end of a phrase followed by the number of words that create the proximity boundary. For example, "hotel airport"~5 will find the terms "hotel" and "airport" within 5 words of each other in a document.

Based on this documentation, I can construct a query that combines fuzzy and proximity search

“Universty~ of~ Washington~”~5 

Note that you must use Lucene query syntax for this to work

like image 152
Matthew Gotteiner Avatar answered Sep 17 '25 02:09

Matthew Gotteiner