List of usage examples for org.apache.lucene.search.spans Spans asTwoPhaseIterator
public TwoPhaseIterator asTwoPhaseIterator()
From source file:uk.co.flax.luwak.util.XConjunctionSpans.java
License:Apache License
/** * Return a {@link TwoPhaseIterator} view of this ConjunctionSpans. *//*w w w .j a v a 2s. com*/ @Override public TwoPhaseIterator asTwoPhaseIterator() { float totalMatchCost = 0; // Compute the matchCost as the total matchCost/positionsCostant of the sub spans. for (Spans spans : subSpans) { TwoPhaseIterator tpi = spans.asTwoPhaseIterator(); if (tpi != null) { totalMatchCost += tpi.matchCost(); } else { totalMatchCost += spans.positionsCost(); } } final float matchCost = totalMatchCost; return new TwoPhaseIterator(conjunction) { @Override public boolean matches() throws IOException { return twoPhaseCurrentDocMatches(); } @Override public float matchCost() { return matchCost; } }; }