# Score and sorting in elastic search

**URL:** <https://discuss.elastic.co/t/score-and-sorting-in-elastic-search/14678>\
**Category:** Elasticsearch\
**Created:** [December 3, 2013, 1:26pm UTC](https://discuss.elastic.co/t/score-and-sorting-in-elastic-search/14678 "2013-12-03T13:26:03Z")\
**Posts on this page:** 2\
**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:** [December 3, 2013, 1:26pm UTC](https://discuss.elastic.co/t/score-and-sorting-in-elastic-search/14678/1 "2013-12-03T13:26:03Z")

</div>

Dear All,

I want to display best possible results for search text such as san and $an.  
I am following below code, where i am searching for san and $an, currently  
in elasticsearch server i do have value stored as San Soda,San Cisco and so  
on.  
I have replaced s with $, because we are searching in 2 ways. I wanted to  
fetch the result related to san first on the top then for $an and rest in  
the bottom as alphabetically but this is not happening with this code

$result = $es-\>search(array(  
"query" =\> array(  
"dis\_max" =\> array(  
"queries" =\> array(  
0 =\> array(  
"field" =\> array(  
"name" =\> 'san'  
)  
),  
1 =\> array(  
"field" =\> array(  
"name" =\> '$an'  
)  
)  
)  
)  
),  
"from" =\> 0,  
"size" =\> 100000,  
"sort" =\> array (  
"\_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/80dc86a5-6a40-4b0c-b155-34ac80dabc3b%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/80dc86a5-6a40-4b0c-b155-34ac80dabc3b%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:** ![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:03am UTC](https://discuss.elastic.co/t/score-and-sorting-in-elastic-search/14678/2 "2017-07-06T02:03:36Z")

</div>


