Skip to content

Commit

Permalink
Added a "_query" field to each object under "hit"."hits" and "queries…
Browse files Browse the repository at this point in the history
…" to indicate which query of which hop that the object relates to.
  • Loading branch information
davemoore- committed Jul 26, 2019
1 parent 1f3e452 commit ac567bb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main/java/io/zentity/resolution/Job.java
Expand Up @@ -584,6 +584,7 @@ private void traverse() throws IOException, ValidationException {
// Prepare to collect attributes from the results of these queries as the inputs to subsequent queries.
Map<String, Attribute> nextInputAttributes = new TreeMap<>();
Boolean newHits = false;
int _query = 0;

// Construct a query for each index that maps to a resolver.
for (String indexName : this.input.model().indices().keySet()) {
Expand Down Expand Up @@ -976,7 +977,7 @@ else if (!resolversClause.isEmpty())
}
String filtersLogged = String.join(",", filtersLoggedList);
String searchLogged = "{\"request\":" + query + ",\"response\":" + responseDataCopyObj + "}";
String logged = "{\"_hop\":" + this.hop + ",\"_index\":\"" + indexName + "\",\"filters\":{" + filtersLogged + "},\"search\":" + searchLogged + "}";
String logged = "{\"_hop\":" + this.hop + ",\"_query\":" + _query + ",\"_index\":\"" + indexName + "\",\"filters\":{" + filtersLogged + "},\"search\":" + searchLogged + "}";
this.queries.add(logged);
}

Expand Down Expand Up @@ -1048,6 +1049,7 @@ else if (!resolversClause.isEmpty())
docObjNode.remove("_score");
docObjNode.remove("fields");
docObjNode.put("_hop", this.hop);
docObjNode.put("_query", _query);
if (this.includeAttributes) {
ObjectNode docAttributesObjNode = docObjNode.putObject("_attributes");
for (String attributeName : docAttributes.keySet()) {
Expand Down Expand Up @@ -1127,6 +1129,7 @@ else if (input.model().matchers().containsKey(matcherName))
this.hits.add(doc.toString());
}
}
_query++;
}

// Stop traversing if we've reached max depth.
Expand Down

0 comments on commit ac567bb

Please sign in to comment.