简体   繁体   中英

Solr Fuzzy Search With Spaces

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM