lux
Class Evaluator

java.lang.Object
  extended by lux.Evaluator

public class Evaluator
extends Object

This class holds all the per-request state required for evaluating queries. It is *not* thread-safe.


Nested Class Summary
 class Evaluator.LuxCollectionURIResolver
           
 class Evaluator.LuxURIResolver
           
 
Field Summary
static String LUX_NAMESPACE
           
 
Constructor Summary
Evaluator()
          Creates a query evaluator that has no association with an index (no searcher or writer).
Evaluator(Compiler compiler, LuxSearcher searcher, DocWriter docWriter)
          Creates an evaluator that uses the provided objects to evaluate queries.
 
Method Summary
 net.sf.saxon.s9api.XdmNode build(Reader xml, String uri)
          Build a document as a Saxon XdmNode.
 void close()
          Call this method to release the Evaluator from its role as the URI and Collection URI Resolver, and to close the underlying Lucene Searcher.
static Evaluator createEvaluator(org.apache.lucene.store.Directory dir)
          Creates a query evaluator that searches and writes to the given Directory (Lucene index).
 XdmResultSet evaluate(String query)
          Compile and evaluate the given query, as XQuery, with no context defined.
 XdmResultSet evaluate(String query, QueryContext context)
           
 XdmResultSet evaluate(net.sf.saxon.s9api.XQueryExecutable xquery)
          Evaluate the already-compiled query, with no context defined.
 XdmResultSet evaluate(net.sf.saxon.s9api.XQueryExecutable xquery, QueryContext context)
           
 Compiler getCompiler()
           
 CachingDocReader getDocReader()
           
 DocWriter getDocWriter()
           
 TransformErrorListener getErrorListener()
           
 LuxQueryParser getLuxQueryParser()
           
 QueryStats getQueryStats()
           
 LuxSearcher getSearcher()
           
 XmlQueryParser getXmlQueryParser()
           
 void reopenSearcher()
          reopen the searcher so it sees any updates.
 void setQueryStats(QueryStats queryStats)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LUX_NAMESPACE

public static final String LUX_NAMESPACE
See Also:
Constant Field Values
Constructor Detail

Evaluator

public Evaluator(Compiler compiler,
                 LuxSearcher searcher,
                 DocWriter docWriter)
Creates an evaluator that uses the provided objects to evaluate queries.

Parameters:
compiler - queries are compiled using this
searcher - search operations required by evaluated queries are carried out using this
docWriter - this writer is used to modify the index (write, delete documents). It must be tied to the same index as the searcher.

Evaluator

public Evaluator()
Creates a query evaluator that has no association with an index (no searcher or writer). A searcher must be supplied in order to compile or evaluate queries that are optimized for use with a Lux (Lucene) index. This constructor is used in testing, or may be useful for compiling and executing queries that don't rely on documents stored in Lucene.

Method Detail

createEvaluator

public static Evaluator createEvaluator(org.apache.lucene.store.Directory dir)
                                 throws IOException
Creates a query evaluator that searches and writes to the given Directory (Lucene index). The Directory is opened and locked; the Evaluator must be closed when it is no longer in use.

Parameters:
dir - the directory where documents are to be searched, store and retrieved
Returns:
the new Evaluator
Throws:
IOException - if the Directory cannot be opened

close

public void close()
Call this method to release the Evaluator from its role as the URI and Collection URI Resolver, and to close the underlying Lucene Searcher.


evaluate

public XdmResultSet evaluate(String query)
Compile and evaluate the given query, as XQuery, with no context defined.

Parameters:
query - an XQuery expression (main module)
Returns:
the results of the evaluation; any errors are encapsulated in the result set.

evaluate

public XdmResultSet evaluate(String query,
                             QueryContext context)

evaluate

public XdmResultSet evaluate(net.sf.saxon.s9api.XQueryExecutable xquery)
Evaluate the already-compiled query, with no context defined.

Parameters:
xquery - a compiled XQuery expression
Returns:
the results of the evaluation; any errors are encapsulated in the result set.

evaluate

public XdmResultSet evaluate(net.sf.saxon.s9api.XQueryExecutable xquery,
                             QueryContext context)

build

public net.sf.saxon.s9api.XdmNode build(Reader xml,
                                        String uri)
Build a document as a Saxon XdmNode. The document will be given a generated id outside the space of ids reserved for indexed documents.

Parameters:
xml - the document content
uri - the document uri
Returns:
the constructed document
Throws:
LuxException - if any error occurs (such as an XML parse error).

reopenSearcher

public void reopenSearcher()
reopen the searcher so it sees any updates. Do NOT call this when operating within Solr: it interferes with Solr's management of open searchers/readers.


getCompiler

public Compiler getCompiler()

getDocReader

public CachingDocReader getDocReader()

getDocWriter

public DocWriter getDocWriter()

getSearcher

public LuxSearcher getSearcher()

getQueryStats

public QueryStats getQueryStats()

setQueryStats

public void setQueryStats(QueryStats queryStats)

getLuxQueryParser

public LuxQueryParser getLuxQueryParser()
Returns:
a new parser, which will be cached for re-use, or the cached parser

getXmlQueryParser

public XmlQueryParser getXmlQueryParser()
Returns:
a new parser, which will be cached for re-use, or the cached parser

getErrorListener

public TransformErrorListener getErrorListener()
Returns:
the error listener that receives static and dynamic error events.


Copyright © 2013. All Rights Reserved.