# Higher score for documents which start with searched word

**URL:** <https://discuss.elastic.co/t/higher-score-for-documents-which-start-with-searched-word/28911>\
**Category:** Elasticsearch\
**Created:** [September 9, 2015, 8:06am UTC](https://discuss.elastic.co/t/higher-score-for-documents-which-start-with-searched-word/28911 "2015-09-09T08:06:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lenych](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lenych/32/4658_2.png) [@lenych](https://discuss.elastic.co/u/lenych)\
**Post date:** [September 9, 2015, 8:06am UTC](https://discuss.elastic.co/t/higher-score-for-documents-which-start-with-searched-word/28911/1 "2015-09-09T08:06:50Z")

</div>

Hello,

I cannot figure out a way to assign higher relevance for the documents based on the order of the searched term in the document field.

For instance, if we search for "egg" in documents: "bagel, egg", "egg, raw, fresh", it should give higher score to the second one, because the word "egg" is first in this document, rather than second as in the other document.

Any ideas are appreciated

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [September 9, 2015, 8:13am UTC](https://discuss.elastic.co/t/higher-score-for-documents-which-start-with-searched-word/28911/2 "2015-09-09T08:13:41Z")

</div>

Hi - you can use multiple clauses in a `bool` query's `should` array. One clause is a basic position-independent match query and one which expects a match at the beginning [1]. Docs that match both clauses would score highest.

[1] [https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-first-query.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-first-query.html)

---

<div class="post-metadata">

**Author:** ![lenych](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lenych/32/4658_2.png) [@lenych](https://discuss.elastic.co/u/lenych)\
**Post date:** [September 9, 2015, 5:46pm UTC](https://discuss.elastic.co/t/higher-score-for-documents-which-start-with-searched-word/28911/3 "2015-09-09T17:46:00Z")

</div>

Thanks a lot, Mark! I think this solves my problem.

---

<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 5, 2017, 11:51pm UTC](https://discuss.elastic.co/t/higher-score-for-documents-which-start-with-searched-word/28911/4 "2017-07-05T23:51:29Z")

</div>


