lux
Class SearchResultIterator

java.lang.Object
  extended by lux.SearchResultIterator
All Implemented Interfaces:
net.sf.saxon.om.SequenceIterator<net.sf.saxon.om.NodeInfo>

public class SearchResultIterator
extends Object
implements net.sf.saxon.om.SequenceIterator<net.sf.saxon.om.NodeInfo>

Executes a Lucene search and provides the results as a Saxon SequenceIterator. Sort criteria are translated into Lucene SortFields: relevance score, intrinsic document order, and field-value orderings are supported.


Field Summary
static MissingStringLastComparatorSource MISSING_LAST
           
 
Fields inherited from interface net.sf.saxon.om.SequenceIterator
GROUNDED, LAST_POSITION_FINDER, LOOKAHEAD
 
Constructor Summary
  SearchResultIterator(Evaluator eval, org.apache.lucene.search.Query query, String sortCriteria, int start)
          Executes a Lucene search.
protected SearchResultIterator(LuxSearcher searcher, CachingDocReader docReader, QueryStats stats, org.apache.lucene.search.Query query, String sortCriteria, int start)
           
 
Method Summary
protected  void advanceTo(int startPosition)
          advance the iterator to (just before) the given (1-based) position.
 void close()
          does nothing
 net.sf.saxon.om.NodeInfo current()
           
 net.sf.saxon.om.SequenceIterator<net.sf.saxon.om.NodeInfo> getAnother()
           
 int getProperties()
          This iterator has no special properties
 net.sf.saxon.om.NodeInfo next()
           
 int position()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MISSING_LAST

public static final MissingStringLastComparatorSource MISSING_LAST
Constructor Detail

SearchResultIterator

public SearchResultIterator(Evaluator eval,
                            org.apache.lucene.search.Query query,
                            String sortCriteria,
                            int start)
                     throws IOException
Executes a Lucene search.

Parameters:
eval - provides the link to the index via its IndexSearcher.
query - the query to execute
sortCriteria - sort criteria, formatted as a comma-separated list of sort field names; each name may be followed by ascending|descending, and/or by "empty greatest"|"empty least". The default is "ascending empty least". The sort criteria are Lucene field names, or may be the special name "lux:score", which selects relevance score ranking, which is always sorted in descending order: modifiers on relevance orders are ignored. If no ordering is provided, results are returned in intrinsic document order (ie ordered by document ID).
start -
Throws:
IOException

SearchResultIterator

protected SearchResultIterator(LuxSearcher searcher,
                               CachingDocReader docReader,
                               QueryStats stats,
                               org.apache.lucene.search.Query query,
                               String sortCriteria,
                               int start)
                        throws IOException
Throws:
IOException
Method Detail

next

public net.sf.saxon.om.NodeInfo next()
                              throws net.sf.saxon.trans.XPathException
Specified by:
next in interface net.sf.saxon.om.SequenceIterator<net.sf.saxon.om.NodeInfo>
Returns:
the next result. Returns null when there are no more results. Calling this function after null has been returned may result in an error.
Throws:
net.sf.saxon.trans.XPathException - if there is an error while searching

advanceTo

protected void advanceTo(int startPosition)
                  throws IOException
advance the iterator to (just before) the given (1-based) position. Sets current to null: next() must be called after this method in order to retrieve the result at the position.

Parameters:
startPosition -
Throws:
IOException

current

public net.sf.saxon.om.NodeInfo current()
Specified by:
current in interface net.sf.saxon.om.SequenceIterator<net.sf.saxon.om.NodeInfo>
Returns:
the current result. This is the last result returned by next(), and will be null if there are no more results.

position

public int position()
Specified by:
position in interface net.sf.saxon.om.SequenceIterator<net.sf.saxon.om.NodeInfo>
Returns:
the (0-based) index of the next result: this will be 0 before any calls to next(), and -1 after the last result has been retrieved.

close

public void close()
does nothing

Specified by:
close in interface net.sf.saxon.om.SequenceIterator<net.sf.saxon.om.NodeInfo>

getAnother

public net.sf.saxon.om.SequenceIterator<net.sf.saxon.om.NodeInfo> getAnother()
                                                                      throws net.sf.saxon.trans.XPathException
Specified by:
getAnother in interface net.sf.saxon.om.SequenceIterator<net.sf.saxon.om.NodeInfo>
Returns:
a clone of this iterator, reset to the initial position.
Throws:
net.sf.saxon.trans.XPathException

getProperties

public int getProperties()
This iterator has no special properties

Specified by:
getProperties in interface net.sf.saxon.om.SequenceIterator<net.sf.saxon.om.NodeInfo>
Returns:
0


Copyright © 2013. All Rights Reserved.