Function Scoring in Percolation

When we are running below function score, it is working fine. But if we run same query using percolation on same document, it isn't working.

Refer to below query:

{
              "function_score": {
                "query": {
                  "bool": {
                    "must": [
                      {
                        "query_string": {
                          "fields": [
                            "field_1"
                          ],
                          "query": "\"apple\""
                        }
                      }
                    ]
                  }
                },
                "score_mode": "sum",
                "script_score": {
                  "script": {
                    "lang": "groovy",
                    "inline": "final_field=[];not_present=[];score = 0;final_score = 0;other_term_score = 0;av_tf = 0;for(field in fields){temp_score = _index[field][skill_term].tf();if(temp_score>0){score=  score+1};else{not_present.push(field);};};for(field in not_present){for(each_term in synonyms){temp_score = _index[field][each_term].tf();if(temp_score>0){score=  score+1};else{final_field.push(field);};};};final_score = ((score*10)/100)+((90*param1)/100);if(divide_flag){return (final_score)/total_demand_score;};else{return final_score;};",
                    "params": {
                      "skill_term": "apple",
                      "fields": [
                        "field_1",
                        "field_2",
                        "field_3",
                        "field_4,
                      ],
                      "divide_flag": true,
                      "total_demand_score": 100,
                      "synonyms": [
                        
                      ],
                      "other_terms": [
                        
                      ],
                      "param1": 0.6738351254480287
                    }
                  }
                },
                "boost_mode": "replace"
              }
            }

I noticed when we are using .tf() in groovy script in percolation, it is not able to compute tf value. We are using this logic at lots of place. we don't use custom scoring then results are not coming good.

Is there any way to solve this ?

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