# Boosting query but score is null

**URL:** <https://discuss.elastic.co/t/boosting-query-but-score-is-null/133142>\
**Category:** Elasticsearch\
**Created:** [May 24, 2018, 12:36pm UTC](https://discuss.elastic.co/t/boosting-query-but-score-is-null/133142 "2018-05-24T12:36:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sherlonv](https://avatars.discourse-cdn.com/v4/letter/s/f4b2a3/32.png) [@sherlonv](https://discuss.elastic.co/u/sherlonv)\
**Post date:** [May 24, 2018, 12:36pm UTC](https://discuss.elastic.co/t/boosting-query-but-score-is-null/133142/1 "2018-05-24T12:36:28Z")

</div>

I'm not familiar when it comes to boosting the score based on a query so I be doing something wrong. But in any case, I seem to have a problem when it comes to generating scores based on boosting. All results come back with a null `score`

I've tried with and without allocating the `boost` param during mapping but both yield the same results.

I'm currently using version 5.4.1 on my local machine.  
Any help regarding the issue would be very much appreciated!  
Line of code on boosted query is below.

```auto
      "query": {
        "bool": {
          "should": [
            {
              "query_string": {
                "query": "*prog*",
                "fields": [
                  "post_name_exact^2",
                  "post_position_exact^2",
                  "post_location_exact",
                  "post_detail"
                ],
                "default_operator": "OR",
                "boost": 2
              }
            }
          ],
          "filter": [
            {
              "term": {
                "post_active": 1
              }
            }
          ]
        }
      },
      "sort": {
        "_score": {
          "order": "asc"
        }
      }
    }
```

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [May 24, 2018, 3:13pm UTC](https://discuss.elastic.co/t/boosting-query-but-score-is-null/133142/2 "2018-05-24T15:13:27Z")

</div>

Hm, can you show the results?

I suspect it's the sort on `_score`, since you're sorting ascending. I think documents that only match the filter on "post\_active" and nothing else will have a null score. Filters don't contribute to scoring, just include/exclude. So a document that _only_ matches that filter clause won't have a score, and since you're sorting ascending (low to high score) the lowest are the docs that don't have any score at all 🙂

Just a guess at this point, but it's probably something similar to that.

---

<div class="post-metadata">

**Author:** ![sherlonv](https://avatars.discourse-cdn.com/v4/letter/s/f4b2a3/32.png) [@sherlonv](https://discuss.elastic.co/u/sherlonv)\
**Post date:** [May 28, 2018, 4:12am UTC](https://discuss.elastic.co/t/boosting-query-but-score-is-null/133142/3 "2018-05-28T04:12:53Z")

</div>

sample reponse as asked, sorry for the late reply 😅

```
"took":1068,
"timed_out":false,
"_shards":{  
   "total":185,
   "successful":118,
   "failed":0
},
"hits":{  
   "total":41,
   "max_score":null,
   "hits":[  
      {  
         "_index":"post",
         "_type":"main",
         "_id":"172363",
         "_score":0,
         "_source":{  
            "profile_id":"1",
            "post_id":"0",
            "post_active":"1",
            "post_created":"2018-04-23 09:17:38",
            "post_updated":"2018-05-09 10:08:44",
            "post_restored":null,
            "post_name":"Jobayan",
            "post_email":" ****",
            "post_phone":" ****",
            "post_position":"Programmer",
            "post_location":" ****",
            "post_geo_location":{  
               "lat":0,
               "lon":0
            },
            "post_experience":"1",
            "post_resume":null,
            "post_detail":null,
            "post_notify":[  
               "matches",
               "likes",
               "sms-interest",
               "sms-match"
            ],
            "post_expires":"2018-05-23 09:17:37",
            "post_image":null,
            "post_banner":null,
            "post_currency":"₱",
            "post_salary_min":"10000",
            "post_salary_max":"20000",
            "post_link":null,
            "post_like_count":"1",
            "post_download_count":"0",
            "post_email_count":"1",
            "post_sms_match_count":"1",
            "post_sms_interested_count":"0",
            "post_phone_count":"0",
            "post_tags":[  

            ],
            "post_arrangement":null,
            "post_package":null,
            "post_type":"poster",
            "post_flag":"1",
            "post_view":"0",
            "post_meta":null,
            "profile_background_color":"rgba(144,210,228,0.29)",
            "profile_gender":"male",
            "profile_birth":"2018-05-09",
         },
         "sort":[  
            0
         ]
      },
      {  
         "_index":"post",
         "_type":"main",
         "_id":"172377",
         "_score":0,
         "_source":{  
            "profile_id":"1",
            "post_id":"0",
            "post_active":"1",
            "post_created":"2018-04-26 16:00:43",
            "post_updated":"2018-04-26 16:00:43",
            "post_restored":null,
            "post_name":"Jobayan",
            "post_email":" ****",
            "post_phone":" ****",
            "post_position":"Position 0011",
            "post_location":" ****",
            "post_geo_location":{  
               "lat":0,
               "lon":0
            },
            "post_experience":"1",
            "post_resume":null,
            "post_detail":null,
            "post_notify":[  
               "matches",
               "likes"
            ],
            "post_expires":"2018-05-26 16:00:42",
            "post_image":null,
            "post_banner":null,
            "post_currency":"₱",
            "post_salary_min":null,
            "post_salary_max":null,
            "post_link":null,
            "post_like_count":"0",
            "post_download_count":"0",
            "post_email_count":"1",
            "post_sms_match_count":"1",
            "post_sms_interested_count":"1",
            "post_phone_count":"1",
            "post_tags":[  
               "Metro"
            ],
            "post_arrangement":null,
            "post_package":null,
            "post_type":"poster",
            "post_flag":"0",
            "post_view":"0",
            "post_meta":null,
            "profile_background_color":"rgba(144,210,228,0.29)",
            "profile_gender":"male",
            "profile_birth":"2018-05-09",
            
            "profile_subscribe":"1",
            "profile_bounce":"0",
            "profile_campaigns":[  
               "test 123"
            ],
            "profile_meta":null,
            "profile_metas":null,
            "post_likes":[  

            ],
            "post_downloads":[  

            ],
            "post_url":" *****",
            "post_name_exact":" ****",
            "post_position_exact":" ****",
            "post_location_exact":" ****"
         },
         "sort":[  
            0
         ]
      }
```

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [May 31, 2018, 2:19pm UTC](https://discuss.elastic.co/t/boosting-query-but-score-is-null/133142/4 "2018-05-31T14:19:08Z")

</div>

Yeah, I think that's what's happening. The scores are both `0`, because presumably the query didn't match... just the filter.

---

<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:** [June 28, 2018, 2:19pm UTC](https://discuss.elastic.co/t/boosting-query-but-score-is-null/133142/5 "2018-06-28T14:19:10Z")

</div>

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