Solr Fuzzy Search With Spaces

554 views Asked by At

I would like to use the Fuzzy Search Feature of Solr. In my dataset, I have one record that looks like this:

{
  "lastName": "John Doe"
}

I would like to perform multiple fuzzy searcheas with the following strings:

  1. John D
  2. John Do
  3. John Doe
  4. John Deo
  5. John Xeo

I perform the query like this:

  1. lastName:"John D"~
  2. lastName:"John Do"~
  3. lastName:"John Doe"~
  4. lastName:"John Deo"~
  5. lastName:"John Xeo"~

I expect, that query 1, 2, 3 and 4 return the record. Unfortunately, only query 3 returns it. As I understand from the documentation, it would be possible to specify the maximum number of edits allowed, when I don't specify something, the edit distance of 2 is used. I think I'm using the syntax incorrectly because if I take a look at my query it looks a lot like a Proximity Search.

But how can I fuzzy search for a string that contains spaces without using a proximity search?

1

There are 1 answers

0
Mirco Widmer On BEST ANSWER

My problem seems to be, that I indeed executed a Proximity Search.

  1. lastName:John\ D~
  2. lastName:John\ Do~
  3. lastName:John\ Doe~
  4. lastName:John\ Deo~
  5. lastName:John\ Xeo~

works exactly like I intend. I have to make sure, all the special characters listed here https://lucene.apache.org/solr/guide/7_3/the-standard-query-parser.html are escaped properly.