# ES sorting not working when use min\_score in query

**URL:** https://discuss.elastic.co/t/es-sorting-not-working-when-use-min-score-in-query/15726
**Category:** Elasticsearch
**Created:** [February 11, 2014, 11:09am UTC](https://discuss.elastic.co/t/es-sorting-not-working-when-use-min-score-in-query/15726 "2014-02-11T11:09:34Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![vallabh](https://avatars.discourse-cdn.com/v4/letter/v/e8c25b/32.png) [@vallabh](https://discuss.elastic.co/u/vallabh)
#### Post date: [February 11, 2014, 11:09am UTC](https://discuss.elastic.co/t/es-sorting-not-working-when-use-min-score-in-query/15726/1 "2014-02-11T11:09:34Z")

</div>

Hello Friends,

When i use "min\_score" in my query sorting stop working.  
Also min\_score displays only 10 results?

Below is my code,

$result = $es-\>search(array(  
"query" =\> array(  
"dis\_max" =\> array(  
"queries" =\> array(  
0 =\> array(  
"field" =\> array(  
"title" =\> $search  
)  
)  
)  
),  
"min\_score" =\> 0.5  
),  
"from" =\> 0,  
"size" =\> 100000,  
"filter" =\> array(  
"geo\_distance" =\> array(  
"distance" =\> "10000mi",  
"jos\_content.location" =\> array(  
"lat" =\> $lat,  
"lon" =\> $lon  
)  
)  
),  
"sort" =\> array(  
0 =\> array(  
"\_geo\_distance" =\> array(  
"jos\_content.location" =\> array(  
"lat" =\> $lat,  
"lon" =\> $lon  
),  
"order" =\> "asc",  
"unit" =\> "km"  
)  
),  
1 =\> "\_score"  
)  
)  
);

Any help is very much appreciated

Thanks,  
Vallabh

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/64245c51-c2ef-42c4-941c-a2add312cfce%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/64245c51-c2ef-42c4-941c-a2add312cfce%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [February 11, 2014, 1:50pm UTC](https://discuss.elastic.co/t/es-sorting-not-working-when-use-min-score-in-query/15726/2 "2014-02-11T13:50:52Z")

</div>

Hey,

can you provide a minimal example using curl, so people can reproduce it  
using commandline tools and do not need a programming language and its  
environment? See [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/help)

A quick test was not revealing any suspicious behaviour to me, but maybe  
you are doing something different.  
Also, what do you mean with 'stops working' - maybe the score is too low to  
be including then? Would be great if you could be more specifc.

Thanks!

--Alex

On Tue, Feb 11, 2014 at 12:09 PM, Vallabh Bothre  
[vallabh.bothre@gmail.com](mailto:vallabh.bothre@gmail.com)wrote:

> Hello Friends,
> 
> When i use "min\_score" in my query sorting stop working.  
> Also min\_score displays only 10 results?
> 
> Below is my code,
> 
> $result = $es-\>search(array(  
> "query" =\> array(  
> "dis\_max" =\> array(  
> "queries" =\> array(  
> 0 =\> array(  
> "field" =\> array(  
> "title" =\> $search  
> )  
> )  
> )  
> ),  
> "min\_score" =\> 0.5  
> ),  
> "from" =\> 0,  
> "size" =\> 100000,  
> "filter" =\> array(  
> "geo\_distance" =\> array(  
> "distance" =\> "10000mi",  
> "jos\_content.location" =\> array(  
> "lat" =\> $lat,  
> "lon" =\> $lon  
> )  
> )  
> ),  
> "sort" =\> array(  
> 0 =\> array(  
> "\_geo\_distance" =\> array(  
> "jos\_content.location" =\> array(  
> "lat" =\> $lat,  
> "lon" =\> $lon  
> ),  
> "order" =\> "asc",  
> "unit" =\> "km"  
> )  
> ),  
> 1 =\> "\_score"  
> )  
> )  
> );
> 
> Any help is very much appreciated
> 
> Thanks,  
> Vallabh
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/64245c51-c2ef-42c4-941c-a2add312cfce%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/64245c51-c2ef-42c4-941c-a2add312cfce%40googlegroups.com)  
> .  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9iUU5DCd5qJE6jAJbU2fsphxGXeqvQiQNzyhi\_xzUMLQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9iUU5DCd5qJE6jAJbU2fsphxGXeqvQiQNzyhi_xzUMLQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![vallabh](https://avatars.discourse-cdn.com/v4/letter/v/e8c25b/32.png) [@vallabh](https://discuss.elastic.co/u/vallabh)
#### Post date: [February 12, 2014, 6:57am UTC](https://discuss.elastic.co/t/es-sorting-not-working-when-use-min-score-in-query/15726/3 "2014-02-12T06:57:26Z")

</div>

Thanks for replying Alex,

You can see my below code so that you can come to know what i am using,

--Creating the index first,  
curl -X PUT '[http://localhost:9200/adminvenue/?pretty=true](http://localhost:9200/adminvenue/?pretty=true)' -d '  
{  
"settings" : {  
"analysis" : {  
"analyzer" : {  
"venue\_analyzer" : {  
"tokenizer" : "standard",  
"filter" : ["standard", "lowercase", "venue\_metaphone",  
"asciifolding"]  
}  
},  
"filter" : {  
"venue\_metaphone" : {  
"type" : "phonetic",  
"encoder" : "metaphone",  
"replace" : false  
}  
}  
}  
}  
}

--Mapping done here  
curl -X PUT '  
[http://localhost:9200/adminvenue/jos\_content/\_mapping?pretty=true](http://localhost:9200/adminvenue/jos_content/_mapping?pretty=true)' -d '  
{  
"jos\_content" : {  
"properties" : {

```
  "title" : {
  "type": "string",
  "index_analyzer": "venue_analyzer",
  "search_analyzer": "venue_analyzer"
  },
  "location" : {

```

"type" : "geo\_point",  
"lat\_lon": true  
}

```
}

```

}  
}

You can search result through browser or by curl, but it is just simple  
search, i am using the above $es-\>search code because i wanted to search  
relaevant data with nearest distance  
[http://localhost:9200/adminvenue/jos\_content/\_search?q=title:palexpo](http://localhost:9200/adminvenue/jos_content/_search?q=title:palexpo)

Sorting stops working means, when i search the data i am sorting  
using \_geo\_distance location.  
So when i get the result it gives me nearest distance of 2 latitude  
longitude.  
But when i used min\_score, i didnot get the nearest distance in the result  
also it gives only 10 results though in the total it is some what more.  
I am using min\_score to remove the non-relevant result.

Thanks,  
Vallabh

On Tuesday, February 11, 2014 7:20:52 PM UTC+5:30, Alexander Reelsen wrote:

> Hey,
> 
> can you provide a minimal example using curl, so people can reproduce it  
> using commandline tools and do not need a programming language and its  
> environment? See [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/help)
> 
> A quick test was not revealing any suspicious behaviour to me, but maybe  
> you are doing something different.  
> Also, what do you mean with 'stops working' - maybe the score is too low  
> to be including then? Would be great if you could be more specifc.
> 
> Thanks!
> 
> --Alex
> 
> On Tue, Feb 11, 2014 at 12:09 PM, Vallabh Bothre \<[vallabh...@gmail.com](mailto:vallabh...@gmail.com)\<javascript:\>
> 
> > wrote:
> 
> > Hello Friends,
> > 
> > When i use "min\_score" in my query sorting stop working.  
> > Also min\_score displays only 10 results?
> > 
> > Below is my code,
> > 
> > $result = $es-\>search(array(  
> > "query" =\> array(  
> > "dis\_max" =\> array(  
> > "queries" =\> array(  
> > 0 =\> array(  
> > "field" =\> array(  
> > "title" =\> $search  
> > )  
> > )  
> > )  
> > ),  
> > "min\_score" =\> 0.5  
> > ),  
> > "from" =\> 0,  
> > "size" =\> 100000,  
> > "filter" =\> array(  
> > "geo\_distance" =\> array(  
> > "distance" =\> "10000mi",  
> > "jos\_content.location" =\> array(  
> > "lat" =\> $lat,  
> > "lon" =\> $lon  
> > )  
> > )  
> > ),  
> > "sort" =\> array(  
> > 0 =\> array(  
> > "\_geo\_distance" =\> array(  
> > "jos\_content.location" =\> array(  
> > "lat" =\> $lat,  
> > "lon" =\> $lon  
> > ),  
> > "order" =\> "asc",  
> > "unit" =\> "km"  
> > )  
> > ),  
> > 1 =\> "\_score"  
> > )  
> > )  
> > );
> > 
> > Any help is very much appreciated
> > 
> > Thanks,  
> > Vallabh
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/64245c51-c2ef-42c4-941c-a2add312cfce%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/64245c51-c2ef-42c4-941c-a2add312cfce%40googlegroups.com)  
> > .  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/a75c11f3-d489-42ec-9916-b441803449f1%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a75c11f3-d489-42ec-9916-b441803449f1%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [February 13, 2014, 8:37am UTC](https://discuss.elastic.co/t/es-sorting-not-working-when-use-min-score-in-query/15726/4 "2014-02-13T08:37:58Z")

</div>

Hey,

you provided the mapping and the index creation calls. In order to really  
reproduce something it would great, if you could also provide a couple of  
documents you created, including the correct geo coordinates.

I have an assumption, which I cannot back up due to missing data now: When  
you are sorting by geo values (and using unit in km) you might be excluding  
everything, which is more distanced than 0.5 km (being the min score) from  
the geo point you defined for sorting. Do you intend to do that?

--Alex

On Wed, Feb 12, 2014 at 7:57 AM, Vallabh Bothre [vallabh.bothre@gmail.com](mailto:vallabh.bothre@gmail.com)wrote:

> Thanks for replying Alex,
> 
> You can see my below code so that you can come to know what i am using,
> 
> --Creating the index first,  
> curl -X PUT '[http://localhost:9200/adminvenue/?pretty=true](http://localhost:9200/adminvenue/?pretty=true)' -d '  
> {  
> "settings" : {  
> "analysis" : {  
> "analyzer" : {  
> "venue\_analyzer" : {  
> "tokenizer" : "standard",  
> "filter" : ["standard", "lowercase",  
> "venue\_metaphone", "asciifolding"]  
> }  
> },  
> "filter" : {  
> "venue\_metaphone" : {  
> "type" : "phonetic",  
> "encoder" : "metaphone",  
> "replace" : false  
> }  
> }  
> }  
> }  
> }
> 
> --Mapping done here  
> curl -X PUT '[http://localhost:9200/adminvenue/jos\_content/\_](http://localhost:9200/adminvenue/jos_content/_)  
> mapping?pretty=true' -d '  
> {  
> "jos\_content" : {  
> "properties" : {
> 
> ```
> "title" : {
> "type": "string",
> "index_analyzer": "venue_analyzer",
> "search_analyzer": "venue_analyzer"
> },
> "location" : {
> 
> ```
> 
> "type" : "geo\_point",  
> "lat\_lon": true  
> }
> 
> ```
> }
> 
> ```
> 
> }  
> }
> 
> You can search result through browser or by curl, but it is just simple  
> search, i am using the above $es-\>search code because i wanted to search  
> relaevant data with nearest distance  
> [http://localhost:9200/adminvenue/jos\_content/\_search?q=title:palexpo](http://localhost:9200/adminvenue/jos_content/_search?q=title:palexpo)
> 
> Sorting stops working means, when i search the data i am sorting  
> using \_geo\_distance location.  
> So when i get the result it gives me nearest distance of 2 latitude  
> longitude.  
> But when i used min\_score, i didnot get the nearest distance in the result  
> also it gives only 10 results though in the total it is some what more.  
> I am using min\_score to remove the non-relevant result.
> 
> Thanks,  
> Vallabh
> 
> On Tuesday, February 11, 2014 7:20:52 PM UTC+5:30, Alexander Reelsen wrote:
> 
> > Hey,
> > 
> > can you provide a minimal example using curl, so people can reproduce it  
> > using commandline tools and do not need a programming language and its  
> > environment? See [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/help)
> > 
> > A quick test was not revealing any suspicious behaviour to me, but maybe  
> > you are doing something different.  
> > Also, what do you mean with 'stops working' - maybe the score is too low  
> > to be including then? Would be great if you could be more specifc.
> > 
> > Thanks!
> > 
> > --Alex
> > 
> > On Tue, Feb 11, 2014 at 12:09 PM, Vallabh Bothre [vallabh...@gmail.com](mailto:vallabh...@gmail.com)wrote:
> > 
> > > Hello Friends,
> > > 
> > > When i use "min\_score" in my query sorting stop working.  
> > > Also min\_score displays only 10 results?
> > > 
> > > Below is my code,
> > > 
> > > $result = $es-\>search(array(  
> > > "query" =\> array(  
> > > "dis\_max" =\> array(  
> > > "queries" =\> array(  
> > > 0 =\> array(  
> > > "field" =\> array(  
> > > "title" =\> $search  
> > > )  
> > > )  
> > > )  
> > > ),  
> > > "min\_score" =\> 0.5  
> > > ),  
> > > "from" =\> 0,  
> > > "size" =\> 100000,  
> > > "filter" =\> array(  
> > > "geo\_distance" =\> array(  
> > > "distance" =\> "10000mi",  
> > > "jos\_content.location" =\> array(  
> > > "lat" =\> $lat,  
> > > "lon" =\> $lon  
> > > )  
> > > )  
> > > ),  
> > > "sort" =\> array(  
> > > 0 =\> array(  
> > > "\_geo\_distance" =\> array(  
> > > "jos\_content.location" =\> array(  
> > > "lat" =\> $lat,  
> > > "lon" =\> $lon  
> > > ),  
> > > "order" =\> "asc",  
> > > "unit" =\> "km"  
> > > )  
> > > ),  
> > > 1 =\> "\_score"  
> > > )  
> > > )  
> > > );
> > > 
> > > Any help is very much appreciated
> > > 
> > > Thanks,  
> > > Vallabh
> > > 
> > > --  
> > > You received this message because you are subscribed to the Google  
> > > Groups "elasticsearch" group.  
> > > To unsubscribe from this group and stop receiving emails from it, send  
> > > an email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).
> > > 
> > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > msgid/elasticsearch/64245c51-c2ef-42c4-941c-a2add312cfce%  
> > > [40googlegroups.com](http://40googlegroups.com).  
> > > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/a75c11f3-d489-42ec-9916-b441803449f1%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a75c11f3-d489-42ec-9916-b441803449f1%40googlegroups.com)  
> > .
> 
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAGCwEM8qbNuKx%3D%2BnfXR21czrMAB6M7%2BR8Maaqe87bio0NbARvw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGCwEM8qbNuKx%3D%2BnfXR21czrMAB6M7%2BR8Maaqe87bio0NbARvw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 1:50am UTC](https://discuss.elastic.co/t/es-sorting-not-working-when-use-min-score-in-query/15726/5 "2017-07-06T01:50:36Z")

</div>


