# The most relevant result does not seem to be the most relevant

**URL:** https://discuss.elastic.co/t/the-most-relevant-result-does-not-seem-to-be-the-most-relevant/9344
**Category:** Elasticsearch
**Created:** [October 12, 2012, 9:21pm UTC](https://discuss.elastic.co/t/the-most-relevant-result-does-not-seem-to-be-the-most-relevant/9344 "2012-10-12T21:21:21Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![mfeingold](https://avatars.discourse-cdn.com/v4/letter/m/ecb155/32.png) [@mfeingold](https://discuss.elastic.co/u/mfeingold)
#### Post date: [October 12, 2012, 9:21pm UTC](https://discuss.elastic.co/t/the-most-relevant-result-does-not-seem-to-be-the-most-relevant/9344/1 "2012-10-12T21:21:21Z")

</div>

I have a list of business names/addresses I run a query against. I assume  
that the query should give me a list of results with the most relevant on  
the top. But the result I see on the top does not seem to me to be the most  
relevant. In particular the results N2 and N3 have much more in common with  
the search string.

The query is here [https://gist.github.com/3881531](https://gist.github.com/3881531) the result of the  
query (including the explain) is here [https://gist.github.com/3881449](https://gist.github.com/3881449) and  
the mapping is here [https://gist.github.com/3881560](https://gist.github.com/3881560)

Any help is greatly appreciated

--

---

<div class="post-metadata">

### Author: ![simonw\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simonw_2/32/1130_2.png) [@simonw\_2](https://discuss.elastic.co/u/simonw_2)
#### Post date: [October 13, 2012, 2:15pm UTC](https://discuss.elastic.co/t/the-most-relevant-result-does-not-seem-to-be-the-most-relevant/9344/2 "2012-10-13T14:15:32Z")

</div>

hey man,

I looked briefly at your query and the mapping and I think this a very very  
uncommon type of query you are running. Given you query including phrases,  
multiple fuzzy searches and your mapping doing ngrams on multiple fields  
with mingram = 1 and maxgram 50 (WOW!!!! crazy!) I don't thing you can  
expect any reasonable results from any search engine on this planet. I am  
happy to help but I think we should start with discussing the problem you  
wanna solve rather than debugging this crazy query, no offense but I  
honestly thing that is hopeless.

Can you explain what you are trying to do? I guess from what I see that you  
want to be able to optimize for recall rather than precision and want to do  
something like an "already spellchecked query"?! would be good if you could  
explain it on a high level.

simon

On Friday, October 12, 2012 11:21:22 PM UTC+2, Michael Feingold wrote:

> I have a list of business names/addresses I run a query against. I assume  
> that the query should give me a list of results with the most relevant on  
> the top. But the result I see on the top does not seem to me to be the most  
> relevant. In particular the results N2 and N3 have much more in common with  
> the search string.
> 
> The query is here [https://gist.github.com/3881531](https://gist.github.com/3881531) the result of the  
> query (including the explain) is here [https://gist.github.com/3881449](https://gist.github.com/3881449) and  
> the mapping is here [https://gist.github.com/3881560](https://gist.github.com/3881560)
> 
> Any help is greatly appreciated

--

---

<div class="post-metadata">

### Author: ![mfeingold](https://avatars.discourse-cdn.com/v4/letter/m/ecb155/32.png) [@mfeingold](https://discuss.elastic.co/u/mfeingold)
#### Post date: [October 15, 2012, 9:34pm UTC](https://discuss.elastic.co/t/the-most-relevant-result-does-not-seem-to-be-the-most-relevant/9344/3 "2012-10-15T21:34:11Z")

</div>

Thank you for your reply. I realize that I posted more 'code' than any  
regular person would care to read. My apologies

Here is what I am trying to do:

I have a list of providers - whatever it is. For every one of them I have  
their name and address as well as a set of ids - there several types of  
them.  
I need to be able to look up providers based on these values. The search  
form has a single field where I expect the user to type whatever info the  
user has - any combination of words (or parts of thereof) as well as ids.

My thinking was that I would index both text part and ids for exact match  
(with a boost) as well as partial - ngrams for wildcards. Probably the  
exact match is redundant, but I wanted to be able to boost the exact match.  
The text partial I also indexed using phonetic filter. Max gram 50 is  
probably an overkill but I really did not see any negative impact,

Now the query combines all of this together plus some fuzziness to help  
with spelling errors.

The funny thing is that the query does what I want it to do. Except for  
when I've shown it to a customer the result on the top of the list was  
something I did not expect - see the attachments. From the first glance the  
result on top was not just the most relevant, it was not relevant at all.

Other than this I am getting what I want, but you made me wonder - did I  
overthink this? is there a better way to do what I need?

On Saturday, October 13, 2012 9:15:32 AM UTC-5, simonw wrote:

> hey man,
> 
> I looked briefly at your query and the mapping and I think this a very  
> very uncommon type of query you are running. Given you query including  
> phrases, multiple fuzzy searches and your mapping doing ngrams on multiple  
> fields with mingram = 1 and maxgram 50 (WOW!!!! crazy!) I don't thing you  
> can expect any reasonable results from any search engine on this planet. I  
> am happy to help but I think we should start with discussing the problem  
> you wanna solve rather than debugging this crazy query, no offense but I  
> honestly thing that is hopeless.
> 
> Can you explain what you are trying to do? I guess from what I see that  
> you want to be able to optimize for recall rather than precision and want  
> to do something like an "already spellchecked query"?! would be good if you  
> could explain it on a high level.
> 
> simon
> 
> On Friday, October 12, 2012 11:21:22 PM UTC+2, Michael Feingold wrote:
> 
> > I have a list of business names/addresses I run a query against. I assume  
> > that the query should give me a list of results with the most relevant on  
> > the top. But the result I see on the top does not seem to me to be the most  
> > relevant. In particular the results N2 and N3 have much more in common with  
> > the search string.
> > 
> > The query is here [https://gist.github.com/3881531](https://gist.github.com/3881531) the result of the  
> > query (including the explain) is here [https://gist.github.com/3881449](https://gist.github.com/3881449) and  
> > the mapping is here [https://gist.github.com/3881560](https://gist.github.com/3881560)
> > 
> > Any help is greatly appreciated

--

---

<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, 3:08am UTC](https://discuss.elastic.co/t/the-most-relevant-result-does-not-seem-to-be-the-most-relevant/9344/4 "2017-07-06T03:08:43Z")

</div>


