Search in sources :

Example 11 with Match

use of org.exist.dom.persistent.Match in project exist by eXist-db.

the class NodeProxies method filterMatches.

/**
 * Filters the full-text matches on the supplied node, leaving only those for which the predicate is true.
 *
 * @param node
 *            the node whose full-text matches are to be filtered
 * @param predicate
 *            the predicate based on which the full-text matches are filtered: If the predicate returns true the
 *            match stays, if not the match is removed.
 */
public static void filterMatches(final NodeProxy node, final Predicate<Match> predicate) {
    Match m = node.getMatches();
    node.setMatches(null);
    while (m != null) {
        if (predicate.test(m)) {
            node.addMatch(m);
        }
        m = m.getNextMatch();
    }
}
Also used : Match(org.exist.dom.persistent.Match)

Example 12 with Match

use of org.exist.dom.persistent.Match in project exist by eXist-db.

the class LuceneMatchListener method startElement.

@Override
public void startElement(final QName qname, final AttrList attribs) throws SAXException {
    Match nextMatch = match;
    // the node contents
    while (nextMatch != null) {
        if (nextMatch.getNodeId().equals(getCurrentNode().getNodeId())) {
            scanMatches(new NodeProxy(getCurrentNode()));
            break;
        }
        nextMatch = nextMatch.getNextMatch();
    }
    super.startElement(qname, attribs);
}
Also used : NodeProxy(org.exist.dom.persistent.NodeProxy) Match(org.exist.dom.persistent.Match)

Aggregations

Match (org.exist.dom.persistent.Match)12 NodeProxy (org.exist.dom.persistent.NodeProxy)7 IOException (java.io.IOException)3 Query (org.apache.lucene.search.Query)2 NodeSet (org.exist.dom.persistent.NodeSet)2 LuceneMatch (org.exist.indexing.lucene.LuceneMatch)2 java.util (java.util)1 IdentityHashMap (java.util.IdentityHashMap)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 XMLStreamReader (javax.xml.stream.XMLStreamReader)1 LogManager (org.apache.logging.log4j.LogManager)1 Logger (org.apache.logging.log4j.Logger)1 PhraseQuery (org.apache.lucene.search.PhraseQuery)1 QName (org.exist.dom.QName)1 DocumentSet (org.exist.dom.persistent.DocumentSet)1 EmptyNodeSet (org.exist.dom.persistent.EmptyNodeSet)1 NewArrayNodeSet (org.exist.dom.persistent.NewArrayNodeSet)1 NGramIndex (org.exist.indexing.ngram.NGramIndex)1