Boosting query but score is null

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.

      "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"
        }
      }
    }

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 :slight_smile:

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

sample reponse as asked, sorry for the late reply :sweat_smile:

"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
         ]
      }

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

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