DSL query for "exact" match in fuzzy searches

(newbie here, I hope it's the correct forum)

Hi all,
I am using elastic to do some fuzzy searches on few indexed text fields, so far so good.
My question: I would like to limit the results as follows:

Let's say that the user searches "mytext":

  1. if "mytext" is not an exact match on any indexed field --> go for the usual fuzzy search
  2. if on the contrary "mytext" is found exactly in one field --> display only that records and skip all the "fuzzy" ones

I have read the multi_match docs but I have had no luck... Anyone willing to help?
Many thanks!
Luigi

You would have to implement this "retry if no matches" logic in your client application.

Elasticsearch is designed to be a distributed system so the query execution logic on one node doesn't know if another node might have found a match for mytext or not.

Your client could issue one msearch request containing a strict and lax version of the searches and only use the lax results if the strict result was empty. That might be more expensive (needlessly running some lax searches) but would mean your client makes only one request.

many thanks, msearch seems exactly what I need
Luigi

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.