# Document score is incorrect?

**URL:** <https://discuss.elastic.co/t/document-score-is-incorrect/10104>\
**Category:** Elasticsearch\
**Created:** [December 18, 2012, 7:24am UTC](https://discuss.elastic.co/t/document-score-is-incorrect/10104 "2012-12-18T07:24:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![NILE\_NGUY\_N](https://avatars.discourse-cdn.com/v4/letter/n/d07c76/32.png) [@NILE\_NGUY\_N](https://discuss.elastic.co/u/NILE_NGUY_N)\
**Post date:** [December 18, 2012, 7:24am UTC](https://discuss.elastic.co/t/document-score-is-incorrect/10104/1 "2012-12-18T07:24:57Z")

</div>

i got stuck when searching with nGram filter

here is my index config  
\*  
localhost:9200/area\*

{

> "name": "translations",  
> "number\_of\_shards": 5,  
> "number\_of\_replicas": 0,  
> "analysis": {  
> "analyzer": {  
> "translation\_index\_analyzer": {  
> "type": "custom",  
> "tokenizer": "standard",  
> "filter": "standard,lowercase,translation,asciifolding"  
> },  
> "translation\_search\_analyzer": {  
> "type": "custom",  
> "tokenizer": "standard",  
> "filter": "standard,lowercase,asciifolding"  
> }  
> },  
> "filter": {  
> "translation": {  
> "type": "nGram",  
> "min\_gram": "2",  
> "max\_gram": "15"  
> }  
> }  
> }  
> }

and my mapping

- \*_localhost:9200/area/detail_

{

> "detail": {  
> "properties": {  
> "area\_name": {  
> "type": "string",  
> "index\_analyzer": "translation\_index\_analyzer",  
> "search\_analyzer": "translation\_search\_analyzer",  
> "term\_vector" : "with\_positions\_offsets"  
> }  
> }  
> }  
> }

_i had done a search with my keyword "ho rua con" and 100% matching in  
elasticsearch document.... but i have another document named "ho con rua"  
... and when i search again .why is "ho rua con" score is equal to "ho con  
rua" score ???_

[https://lh4.googleusercontent.com/-gxBFt3exabU/UNAZasY1z9I/AAAAAAAAAI4/K79AKTzaz1g/s1600/2012-12-18\_140158.png](https://lh4.googleusercontent.com/-gxBFt3exabU/UNAZasY1z9I/AAAAAAAAAI4/K79AKTzaz1g/s1600/2012-12-18_140158.png)  
SORRY FOR MY BAD ENGLISH

--

---

<div class="post-metadata">

**Author:** ![phill](https://avatars.discourse-cdn.com/v4/letter/p/779978/32.png) [@phill](https://discuss.elastic.co/u/phill)\
**Post date:** [December 18, 2012, 6:04pm UTC](https://discuss.elastic.co/t/document-score-is-incorrect/10104/2 "2012-12-18T18:04:28Z")

</div>

On 12/17/2012 11:24 PM, NILE NGUYỄN wrote:

> _i had done a search with my keyword "ho rua con" and 100% matching in  
> elasticsearch document.... but i have another document named "ho con  
> rua" ... and when i search again .why is "ho rua con" score is equal  
> to "ho con rua" score ???_
> 
> [https://lh4.googleusercontent.com/-gxBFt3exabU/UNAZasY1z9I/AAAAAAAAAI4/K79AKTzaz1g/s1600/2012-12-18\_140158.png](https://lh4.googleusercontent.com/-gxBFt3exabU/UNAZasY1z9I/AAAAAAAAAI4/K79AKTzaz1g/s1600/2012-12-18_140158.png)  
> SORRY FOR MY BAD ENGLISH
> 
> --  
> Your English is fine. Your English is a lot better than many postings on  
> the internet. It seems clear to me. I think the longer phrases help a lot.

query\_string takes what you enter and interprets not as a phrase, but as  
individual parts of a Lucene query expression.  
Therefore [ho] and [rua] and [con] are interpreted as separate terms  
instead of a phrase.

query: { \<--- the outer query that you are building

bool: { \<-- the query used to put together everything you add with the [+] button.

```
  must: [ <-- your defined use of must to combine this expression in the overall boolean query

    { "bool" : { <-- my expansion of the query_string

      "should": [ <-- default for Lucene queries

          {term: { "testarea_name":"ho"}, <-- your terms in the "generated" query
          {term: { "testarea_name":"rua"},
          {term: { "testarea_name":"con"}

      ]
    }
  ]
}

```

}

I've shown it in ES format, even though it is never an ES query. It goes  
directly to Lucene.  
In Lucene

[ho rua con] becomes [testarea\_name:ho testarea\_name:rua testarea\_name:con]

I am using square brackets to delineate queries, because I find it confusing  
to use quotes, because quotes are special syntax in Lucene queries.

If you want a phrase, use quotes ["ho rua con"]. In the search box you  
enter actual quotes.  
You can then add slop (total extra words allowed) and even boost after  
the quotes.

-Paul

--

---

<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, 2:59am UTC](https://discuss.elastic.co/t/document-score-is-incorrect/10104/3 "2017-07-06T02:59:26Z")

</div>


