# Add score +30 if doc\['someField'\].value == "some"

**URL:** <https://discuss.elastic.co/t/add-score-30-if-doc-somefield-value-some/143516>\
**Category:** Elasticsearch\
**Created:** [August 8, 2018, 12:49pm UTC](https://discuss.elastic.co/t/add-score-30-if-doc-somefield-value-some/143516 "2018-08-08T12:49:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ConConovaloff](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/conconovaloff/32/34258_2.png) [@ConConovaloff](https://discuss.elastic.co/u/ConConovaloff)\
**Post date:** [August 8, 2018, 12:49pm UTC](https://discuss.elastic.co/t/add-score-30-if-doc-somefield-value-some/143516/1 "2018-08-08T12:49:51Z")

</div>

Hello

I have document:  
{  
"\_id": 111  
"price": 1000  
"color": "red"  
}

I'm use function\_score with gauss function for get score by price.  
Now, i need add +30 score if color == "green". Preferably without use groovy script.  
But, if color != "green", then still get this document in result, just without these extra 30 points score.  
There are ideas in which direction to look?

Thank you

---

<div class="post-metadata">

**Author:** ![ConConovaloff](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/conconovaloff/32/34258_2.png) [@ConConovaloff](https://discuss.elastic.co/u/ConConovaloff)\
**Post date:** [August 9, 2018, 8:32am UTC](https://discuss.elastic.co/t/add-score-30-if-doc-somefield-value-some/143516/2 "2018-08-09T08:32:55Z")

</div>

I'm have solution:

> ```
> {
> "query": {
> "bool": {
> "should": [
> {
> "match_all": {}
> },
> {
> "constant_score": {
> "filter": {
> "term": {
> "color": "red"
> }
> },
> "boost": 30
> }
> }
> ]
> }
> },
> "sort": {
> "_score": {
> "order": "desc"
> }
> }
> }
> 
> ```

I've tried this request before, but it returned an incorrect result due to the fact that I used the old version. As soon as I updated from 2 to 6 versions, the problem disappeared

---

<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:** [September 6, 2018, 8:36am UTC](https://discuss.elastic.co/t/add-score-30-if-doc-somefield-value-some/143516/3 "2018-09-06T08:36:30Z")

</div>

Closed on September 6, 2018, 8:36am UTC

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