Query-as-you-type problems with scoring and misspellings

(Peter Lundström) #1


I have an index with a large number of people in it. I want to implement search-as-you-type functionality but I don't get hits in the order I expect and sometimes I don't get any hits at all.

The names are stored in a single "name"-field.

In my index there are more than 20 people named "Anders Johansson" (with that exact spelling), and there are also a lot of people with names similar to "Anders Johansson", for instance: "Anderz Johansson", "Anders Johanesson", "Anderas Johansson" etc.

What I want is a query that returns all the "Anders Johansson"s as the top hits when I search for any of the following:

"Anders Johansson" (A match query towards the name-field with fuzziness set to 0.1 returns all the similar examples above BEFORE (higher score than) the first real "Anders Johansson"-hit)

"Anders Johans" (A match_phrase_prefix returns what I want here)

"Anderk Johans" (Anders is misspelled here. This returns zero answers with a match_phrase_prefix query no matter what I set fuzziness to.)

Is there a query that works like match_phrase_prefix (last word not yet completed) that also handles spelling mistakes in one of the first words?

I have tried match, match_phrase_prefix and fuzzy-queries, with different combinations of fuzziness, slop and max_expansions, but I can't find one the handles all of the situations above.


(system) #2