use of org.apache.tinkerpop.shaded.jackson.databind.JsonNode in project unipop by unipop-graph.
the class AbstractDocSchema method parseResults.
@Override
public List<E> parseResults(String result, PredicateQuery query) {
List<E> results = new ArrayList<>();
try {
JsonNode hits = mapper.readTree(result).get("hits").get("hits");
for (JsonNode hit : hits) {
Map<String, Object> source = hit.has("_source") ? mapper.readValue(hit.get("_source").toString(), Map.class) : new HashMap<>();
Document document = new Document(hit.get("_index").asText(), hit.get("_type").asText(), hit.get("_id").asText(), source);
Collection<E> elements = fromDocument(document);
if (elements != null) {
elements.forEach(element -> {
if (element != null && query.test(element, query.getPredicates()))
results.add(element);
});
}
}
} catch (IOException e) {
e.printStackTrace();
}
return results;
}
Aggregations