# Boost only first document matching criteria

**URL:** https://discuss.elastic.co/t/boost-only-first-document-matching-criteria/20555
**Category:** Elasticsearch
**Created:** [November 4, 2014, 11:11am UTC](https://discuss.elastic.co/t/boost-only-first-document-matching-criteria/20555 "2014-11-04T11:11:06Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Jurian\_Sluiman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jurian_sluiman/32/1128_2.png) [@Jurian\_Sluiman](https://discuss.elastic.co/u/Jurian_Sluiman)
#### Post date: [November 4, 2014, 11:11am UTC](https://discuss.elastic.co/t/boost-only-first-document-matching-criteria/20555/1 "2014-11-04T11:11:06Z")

</div>

This sounds perhaps as a non-ES use case, but I would like to have a single  
document which has a certain flag boost to the top of the results.

I have ~10% of the documents with a flag. All documents (disregarding the  
flag) are sorted on \_timestamp. All fields have a \_boost by default of 1.0.  
Now I would like to keep the sort the same, _except_ for the _first  
document_ matching a non-null value for specified flag. In other words, the  
latest (chronologically) flagged document should be the 1st result, all  
other documents (with or without flag) are sorted "just" based on  
\_timestamp.

Is this possible with ES? I have been thinking about the ES index where I  
set a \_boost value of \>1.0 for a flagged document and each time I insert a  
new flagged document, I update all flagged documents in the index with a  
boost of 1.0, effectively resetting the boost every time. But as this is  
such a nasty solution, I hope ES users will help me with some more insights  
🙂

--  
Jurian

--  
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/787640ea-fb79-4f65-b294-34c4e21fba87%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/787640ea-fb79-4f65-b294-34c4e21fba87%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:52am UTC](https://discuss.elastic.co/t/boost-only-first-document-matching-criteria/20555/2 "2017-07-06T00:52:17Z")

</div>


