use of com.enonic.xp.repo.impl.search.result.SearchHit in project xp by enonic.
the class FindNodesByQueryResultFactory method create.
static FindNodesByQueryResult create(final SearchResult result) {
final FindNodesByQueryResult.Builder resultBuilder = FindNodesByQueryResult.create().hits(result.getNumberOfHits()).totalHits(result.getTotalHits()).aggregations(result.getAggregations()).suggestions(result.getSuggestions());
for (final SearchHit hit : result.getHits()) {
final NodeHit.Builder nodeHit = NodeHit.create().nodeId(NodeId.from(hit.getId())).score(hit.getScore()).explanation(hit.getExplanation()).highlight(hit.getHighlightedProperties()).sort(hit.getSortValues());
final String nodePath = (String) hit.getReturnValues().getSingleValue(NodeIndexPath.PATH.getPath());
if (nodePath != null) {
nodeHit.nodePath(NodePath.create(nodePath).build());
}
resultBuilder.addNodeHit(nodeHit.build());
}
return resultBuilder.build();
}
use of com.enonic.xp.repo.impl.search.result.SearchHit in project xp by enonic.
the class FindNodesDependenciesCommand method addNodeIdsFromReferenceReturnValues.
private void addNodeIdsFromReferenceReturnValues(final SearchResult result, final NodeIds.Builder builder) {
for (SearchHit hit : result.getHits()) {
final ReturnValue returnValue = hit.getReturnValues().get(NodeIndexPath.REFERENCE.getPath());
if (returnValue == null || returnValue.getValues().isEmpty()) {
continue;
}
returnValue.getValues().stream().map((value) -> NodeId.from(value.toString())).filter((value) -> !processed.contains(value)).filter((value) -> !excludedIds.contains(value)).forEach(builder::add);
}
}
use of com.enonic.xp.repo.impl.search.result.SearchHit in project xp by enonic.
the class NodeVersionDiffResultFactory method create.
public static NodeVersionDiffResult create(final SearchResult result) {
if (result.isEmpty()) {
return NodeVersionDiffResult.create().totalHits(result.getTotalHits()).build();
}
final NodeVersionDiffResult.Builder builder = NodeVersionDiffResult.create();
builder.totalHits(result.getTotalHits());
for (final SearchHit hit : result.getHits()) {
builder.add(NodeId.from(hit.getField(VersionIndexPath.NODE_ID.toString()).getSingleValue().toString()));
}
return builder.build();
}
Aggregations