Skip to content

Commit

Permalink
Bug fix: When checking the existence of a resolver with a higher weig…
Browse files Browse the repository at this point in the history
…ht, 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.
  • Loading branch information
davemoore- committed Jul 18, 2019
1 parent a8e006e commit 4d97d39
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/main/java/io/zentity/resolution/Job.java
Original file line number Diff line number Diff line change
Expand Up @@ -688,11 +688,15 @@ else if (size == 1)
List<String> parentResolverClauses = new ArrayList<>();
for (String parentResolverName : parentResolversGroup) {

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

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

0 comments on commit 4d97d39

Please sign in to comment.