Skip to content

Commit 4d97d39

Browse files
committed
Bug fix: When checking the existence of a resolver with a higher weight, the absence of any attribute should imply that the resolver does not exist. Until now the boolean logic had checked for the absence of all attributes of the resolver. This has been corrected to check for the absence of any attribute of the resolver.
1 parent a8e006e commit 4d97d39

File tree

1 file changed

+7
-3
lines changed
  • src/main/java/io/zentity/resolution

1 file changed

+7
-3
lines changed

src/main/java/io/zentity/resolution/Job.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -688,11 +688,15 @@ else if (size == 1)
688688
List<String> parentResolverClauses = new ArrayList<>();
689689
for (String parentResolverName : parentResolversGroup) {
690690

691-
// Construct a clause that checks if every attribute of the resolver does not exist.
691+
// Construct a clause that checks if any attribute of the resolver does not exist.
692692
List<String> attributeExistsClauses = new ArrayList<>();
693693
for (String attributeName : this.input.model().resolvers().get(parentResolverName).attributes())
694-
attributeExistsClauses.add("{\"exists\":{\"field\":\"" + attributeName + "\"}}");
695-
String attributesExistsClause = "{\"bool\":{\"must_not\":[" + String.join(",", attributeExistsClauses) + "]}}";
694+
attributeExistsClauses.add("{\"bool\":{\"must_not\":{\"exists\":{\"field\":\"" + attributeName + "\"}}}}");
695+
String attributesExistsClause = "";
696+
if (attributeExistsClauses.size() > 1)
697+
attributesExistsClause = "{\"bool\":{\"should\":[" + String.join(",", attributeExistsClauses) + "]}}";
698+
else if (attributeExistsClauses.size() == 1)
699+
attributesExistsClause = attributeExistsClauses.get(0);
696700

697701
// Construct a clause for the resolver.
698702
List<String> parentResolverGroup = new ArrayList<>(Arrays.asList(parentResolverName));

0 commit comments

Comments
 (0)