Skip to content

Commit

Permalink
fix(OpenSearchClient): boostScore totalVotes nullable checks
Browse files Browse the repository at this point in the history
Using OpenSearch 2.9 an exception is  raised when we try to check if a property of long type is missing with doc['field'].value != null
  • Loading branch information
heitorrbarros committed May 9, 2024
1 parent a8fe40c commit f5b9b67
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ private Response searchPipelineLineage(
private static ScriptScoreFunctionBuilder boostScore() {
return ScoreFunctionBuilders.scriptFunction(
"double score = _score;"
+ "if (doc.containsKey('totalVotes') && doc['totalVotes'].value != null) { score = score + doc['totalVotes'].value; }"
+ "if (doc.containsKey('totalVotes') && doc['totalVotes'].size() != 0) { score = score + doc['totalVotes'].value; }"
+ "if (doc.containsKey('usageSummary') && doc['usageSummary.weeklyStats.count'].value != null) { score = score + doc['usageSummary.weeklyStats.count'].value; }"
+ "if (doc.containsKey('tier.tagFQN') && !doc['tier.tagFQN'].empty) { if (doc['tier.tagFQN'].value == 'Tier.Tier2') { score = score + 10; }"
+ " else if (doc['tier.tagFQN'].value == 'Tier.Tier1') { score = score + 20; }}"
Expand Down

0 comments on commit f5b9b67

Please sign in to comment.