# ES defaults not exhibiting typical Lucene behavior

**URL:** <https://discuss.elastic.co/t/es-defaults-not-exhibiting-typical-lucene-behavior/8956>\
**Category:** Elasticsearch\
**Created:** [September 7, 2012, 5:11pm UTC](https://discuss.elastic.co/t/es-defaults-not-exhibiting-typical-lucene-behavior/8956 "2012-09-07T17:11:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Allison\_A](https://avatars.discourse-cdn.com/v4/letter/a/7ba0ec/32.png) [@Allison\_A](https://discuss.elastic.co/u/Allison_A)\
**Post date:** [September 7, 2012, 5:11pm UTC](https://discuss.elastic.co/t/es-defaults-not-exhibiting-typical-lucene-behavior/8956/1 "2012-09-07T17:11:52Z")

</div>

I have a field "CategoryMajor"

I have two documents:  
Doc 1: CategoryMajor: Restaurants  
Doc 2: CategoryMajor: Restaurants, Restaurants, Restaurants, Restaurants,  
Restaurants

If I search for CategoryMajor:Restaurants, then Doc #1 is more relevant  
than Doc #2.

Why is this, and how do I remedy this?

Thanks,  
Allison

--

---

<div class="post-metadata">

**Author:** ![Allison\_A](https://avatars.discourse-cdn.com/v4/letter/a/7ba0ec/32.png) [@Allison\_A](https://discuss.elastic.co/u/Allison_A)\
**Post date:** [September 7, 2012, 6:31pm UTC](https://discuss.elastic.co/t/es-defaults-not-exhibiting-typical-lucene-behavior/8956/2 "2012-09-07T18:31:04Z")

</div>

I've provided some output below. The 4 instances of the term should be most  
relevant, then the two, and one last. Yet this is not the case...

[http://localhost:9200/test/type1/\_search?pretty=true&q=cat:restaurants](http://localhost:9200/test/type1/_search?pretty=true&q=cat:restaurants)

{  
"took" : 10,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 5,  
"successful" : 5,  
"failed" : 0  
},  
"hits" : {  
"total" : 3,  
"max\_score" : 0.30685282,  
"hits" : [ {  
"\_index" : "test",  
"\_type" : "type1",  
"\_id" : "doc2",  
"\_score" : 0.30685282, "\_source" : {"cat": "restaurants restaurants restaurants restaurants"}  
}, {  
"\_index" : "test",  
"\_type" : "type1",  
"\_id" : "doc3",  
"\_score" : 0.30685282, "\_source" : {"cat": "restaurants"}  
}, {  
"\_index" : "test",  
"\_type" : "type1",  
"\_id" : "doc1",  
"\_score" : 0.2712221, "\_source" : {"cat": "restaurants restaurants"}  
} ]  
}  
}

On Friday, September 7, 2012 1:11:52 PM UTC-4, Allison A. wrote:

> I have a field "CategoryMajor"
> 
> I have two documents:  
> Doc 1: CategoryMajor: Restaurants  
> Doc 2: CategoryMajor: Restaurants, Restaurants, Restaurants, Restaurants,  
> Restaurants
> 
> If I search for CategoryMajor:Restaurants, then Doc #1 is more relevant  
> than Doc #2.
> 
> Why is this, and how do I remedy this?
> 
> Thanks,  
> Allison

--

---

<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:** [September 7, 2012, 9:39pm UTC](https://discuss.elastic.co/t/es-defaults-not-exhibiting-typical-lucene-behavior/8956/3 "2012-09-07T21:39:18Z")

</div>

What does your mapping look like? That can effect scoring.

[http://localhost:9200/test/type1/\_mapping?pretty=true](http://localhost:9200/test/type1/_mapping?pretty=true)

-Paul

On 9/7/2012 11:31 AM, Allison A. wrote:

> I've provided some output below. The 4 instances of the term should be  
> most relevant, then the two, and one last. Yet this is not the case...
> 
> [http://localhost:9200/test/type1/\_search?pretty=true&q=cat:restaurants](http://localhost:9200/test/type1/_search?pretty=true&q=cat:restaurants)
> 
> {  
> "took" : 10,  
> "timed\_out" : false,  
> "\_shards" : {  
> "total" : 5,  
> "successful" : 5,  
> "failed" : 0  
> },  
> "hits" : {  
> "total" : 3,  
> "max\_score" : 0.30685282,  
> "hits" : [ {  
> "\_index" : "test",  
> "\_type" : "type1",  
> "\_id" : "doc2",  
> "\_score" : 0.30685282, "\_source" : {"cat": "restaurants restaurants restaurants restaurants"}  
> }, {  
> "\_index" : "test",  
> "\_type" : "type1",  
> "\_id" : "doc3",  
> "\_score" : 0.30685282, "\_source" : {"cat": "restaurants"}  
> }, {  
> "\_index" : "test",  
> "\_type" : "type1",  
> "\_id" : "doc1",  
> "\_score" : 0.2712221, "\_source" : {"cat": "restaurants restaurants"}  
> } ]  
> }  
> }
> 
> On Friday, September 7, 2012 1:11:52 PM UTC-4, Allison A. wrote:
> 
> ```
> I have a field "CategoryMajor"
> 
> I have two documents:
> Doc 1: CategoryMajor: Restaurants
> Doc 2: CategoryMajor: Restaurants, Restaurants, Restaurants,
> Restaurants, Restaurants
> 
> If I search for CategoryMajor:Restaurants, then Doc #1 is more
> relevant than Doc #2.
> 
> Why is this, and how do I remedy this?
> 
> Thanks,
> Allison
> 
> ```
> 
> --

--

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [September 10, 2012, 8:25am UTC](https://discuss.elastic.co/t/es-defaults-not-exhibiting-typical-lucene-behavior/8956/4 "2012-09-10T08:25:11Z")

</div>

Hi Allison

On Fri, 2012-09-07 at 11:31 -0700, Allison A. wrote:

> I've provided some output below. The 4 instances of the term should be  
> most relevant, then the two, and one last. Yet this is not the case...

You really need to provide a full recreation of the problem. That allows  
us to test it locally. See [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/help)

However, my guess would be that it is a combination of a few factors:

1. you have few docs, and you are using the default of 5 primary shards,  
so your terms are not yet well distributed. You can eliminate this  
problem by:

2. You are testing short bits of text. The "norm" for a field is stored  
(in Lucene \< 4) in a single byte. So a field with 1 token may be  
considered to be the same "length" as a field with 2-4 tokens

clint

> [http://localhost:9200/test/type1/\_search?pretty=true&q=cat:restaurants](http://localhost:9200/test/type1/_search?pretty=true&q=cat:restaurants)
> 
> {  
> "took" : 10,  
> "timed\_out" : false,  
> "\_shards" : {  
> "total" : 5,  
> "successful" : 5,  
> "failed" : 0  
> },  
> "hits" : {  
> "total" : 3,  
> "max\_score" : 0.30685282,  
> "hits" : [ {  
> "\_index" : "test",  
> "\_type" : "type1",  
> "\_id" : "doc2",  
> "\_score" : 0.30685282, "\_source" : {"cat": "restaurants restaurants restaurants restaurants"}  
> }, {  
> "\_index" : "test",  
> "\_type" : "type1",  
> "\_id" : "doc3",  
> "\_score" : 0.30685282, "\_source" : {"cat": "restaurants"}  
> }, {  
> "\_index" : "test",  
> "\_type" : "type1",  
> "\_id" : "doc1",  
> "\_score" : 0.2712221, "\_source" : {"cat": "restaurants restaurants"}  
> } ]  
> }  
> }
> 
> On Friday, September 7, 2012 1:11:52 PM UTC-4, Allison A. wrote:  
> I have a field "CategoryMajor"
> 
> ```
> I have two documents:
> Doc 1: CategoryMajor: Restaurants
> Doc 2: CategoryMajor: Restaurants, Restaurants, Restaurants,
> Restaurants, Restaurants
>     
>     
> If I search for CategoryMajor:Restaurants, then Doc #1 is more
> relevant than Doc #2.
>     
>     
> Why is this, and how do I remedy this?
>     
>     
> Thanks,
> Allison
> 
> ```
> 
> --

--

---

<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:13am UTC](https://discuss.elastic.co/t/es-defaults-not-exhibiting-typical-lucene-behavior/8956/5 "2017-07-06T03:13:25Z")

</div>

Closed on July 6, 2017, 3:13am UTC


