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

**URL:** <https://discuss.elastic.co/t/query-as-you-type-problems-with-scoring-and-misspellings/1923>\
**Category:** Elasticsearch\
**Created:** [June 4, 2015, 11:31am UTC](https://discuss.elastic.co/t/query-as-you-type-problems-with-scoring-and-misspellings/1923 "2015-06-04T11:31:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Peter\_Lundstrom](https://avatars.discourse-cdn.com/v4/letter/p/f08c70/32.png) [@Peter\_Lundstrom](https://discuss.elastic.co/u/Peter_Lundstrom)\
**Post date:** [June 4, 2015, 11:31am UTC](https://discuss.elastic.co/t/query-as-you-type-problems-with-scoring-and-misspellings/1923/1 "2015-06-04T11:31:04Z")

</div>

Hi,

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.

/Peter

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 12:09am UTC](https://discuss.elastic.co/t/query-as-you-type-problems-with-scoring-and-misspellings/1923/2 "2017-07-06T00:09:40Z")

</div>


