try {
JackrabbitIndexSearcher searcher = new JackrabbitIndexSearcher(
session, reader, index.getContext().getItemStateManager());
searcher.setSimilarity(index.getSimilarity());
Predicate filter = Predicate.TRUE;
BooleanQuery query = new BooleanQuery();
QueryPair qp = new QueryPair(query);
query.add(create(selector), MUST);
if (constraint != null) {
String name = selector.getSelectorName();
NodeType type =
ntManager.getNodeType(selector.getNodeTypeName());
filter = mapConstraintToQueryAndFilter(qp,
constraint, Collections.singletonMap(name, type),
searcher, reader);
}
// Added by jahia
Set<String> foundIds = new HashSet<String>();
List<ScoreNode> nodes = new ArrayList<ScoreNode>();
// End
List<Row> rows = new ArrayList<Row>();
QueryHits hits = searcher.evaluate(qp.mainQuery);
ScoreNode node = hits.nextScoreNode();
while (node != null) {
if (foundIds.add(getId(node, reader))) { // <-- Added by jahia
try {
NodeImpl objectNode = session.getNodeById(node.getNodeId());
if (objectNode.isNodeType("jnt:translation")) {
objectNode = (NodeImpl) objectNode.getParent();
}
Row row = new SelectorRow(
columns, evaluator, selector.getSelectorName(),
provider.getNodeWrapper(objectNode, jcrSession),
node.getScore());
if (filter.evaluate(row)) {
rows.add(row);
nodes.add(node); // <-- Added by jahia
}
} catch (PathNotFoundException e) {
} catch (ItemNotFoundException e) {