# How to implement ranking based on many fields?

**URL:** <https://discuss.elastic.co/t/how-to-implement-ranking-based-on-many-fields/9502>\
**Category:** Elasticsearch\
**Created:** [October 30, 2012, 3:57pm UTC](https://discuss.elastic.co/t/how-to-implement-ranking-based-on-many-fields/9502 "2012-10-30T15:57:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![11111](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/11111/32/2406_2.png) [@11111](https://discuss.elastic.co/u/11111)\
**Post date:** [October 30, 2012, 3:57pm UTC](https://discuss.elastic.co/t/how-to-implement-ranking-based-on-many-fields/9502/1 "2012-10-30T15:57:42Z")

</div>

When user types something like "\*italian restaurant with wi-fi at 5th avenue  
\*", I want to find document with:  
_address_ (string) - 5th avenue  
_kitchens_ (array of strings) - italian  
_categories_ (array of strings) - restaurant  
_fields.name_ (string) - wi-fi (exists only when wi-fi = true)  
"with" and "at" are already added to stopwords.

In Sphinx (Rails&ThinkingSphinx) it was done by: _Place.search 'italian  
restaurant with wi-fi on 5th avenue', :match\_mode =\> :extended_  
But Sphinx uses proximity\_bm25 ranking mode.

How can I achieve the same result with ES?  
Searching with text '\_all' gives no results at all, searching with dis\_max  
and many bools gives wrong ranking [https://gist.github.com/3945005](https://gist.github.com/3945005).

--

---

<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:06am UTC](https://discuss.elastic.co/t/how-to-implement-ranking-based-on-many-fields/9502/2 "2017-07-06T03:06:47Z")

</div>


