# Scoring Elasticsearch by postion of query term in the indexed document

**URL:** <https://discuss.elastic.co/t/scoring-elasticsearch-by-postion-of-query-term-in-the-indexed-document/138332>\
**Category:** Elasticsearch\
**Created:** [July 3, 2018, 8:23am UTC](https://discuss.elastic.co/t/scoring-elasticsearch-by-postion-of-query-term-in-the-indexed-document/138332 "2018-07-03T08:23:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tahir\_Ahmad](https://avatars.discourse-cdn.com/v4/letter/t/439d5e/32.png) [@Tahir\_Ahmad](https://discuss.elastic.co/u/Tahir_Ahmad)\
**Post date:** [July 3, 2018, 8:23am UTC](https://discuss.elastic.co/t/scoring-elasticsearch-by-postion-of-query-term-in-the-indexed-document/138332/1 "2018-07-03T08:23:15Z")

</div>

I mean if I have When I index say following documents :

doc 1: coconut red orange  
doc 2: orange coconut apple  
doc 3: coconut orange apple

I search for a term "coconut" and get I following result:

rank 1: coconut red orange  
rank 2: orange coconut apple  
rank 3: coconut orange apple

All the docs have same score.

My disered output would have been :

coconut red orange  
coconut orange apple  
orange coconut apple

The term which I am searching for is at the start of the document needs to be ranked better than where it appears later.

I can't figure out how to make that happen. Term position isn't factored into the default scoring logic, and I can't find a way to get it in there. Seems like a simple enough issue though that others must have run into this before. Has anyone figured it out yet?

Thanks!

---

<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 31, 2018, 8:23am UTC](https://discuss.elastic.co/t/scoring-elasticsearch-by-postion-of-query-term-in-the-indexed-document/138332/2 "2018-07-31T08:23:15Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
