lux.compiler
Class XPathQuery

java.lang.Object
  extended by lux.compiler.XPathQuery

public class XPathQuery
extends Object

Wraps a Lucene Query, with advice as to how to process its results as XPath. For now, simply distinguishes the two cases: whether the results are in fact supposed to be the results of the original XPath evaluation, or if further evaluation is needed.


Field Summary
static int BOOLEAN_FALSE
          A query is boolean_false if its result type is boolean, and the existence of a single query result indicates a 'false()' value
static int EMPTY
          queries that match all documents (have no filter) are empty.
static int EXACT
          A query is exact iff its xpath expression returns exactly one value per document, and the generated lucene query returns exactly those documents satisfying the xpath expression.
static int IGNORABLE
          If a query a is ignorable, then combine(a,b) = b unless b is also ignorable, in which case combine(a,b) = a|b
static XPathQuery MATCH_ALL
           
static int MINIMAL
          A query is minimal if it returns all, and only, those documents satisfying the xpath expression.
static int SINGULAR
          An expression is singular if it returns a single result for every matching document.
 
Constructor Summary
protected XPathQuery(ParseableQuery query, long resultFacts, ValueType valueType)
           
protected XPathQuery(ParseableQuery query, long resultFacts, ValueType valueType, boolean immutable)
           
 
Method Summary
 XPathQuery combineBooleanQueries(org.apache.lucene.search.BooleanClause.Occur occur, XPathQuery precursor, org.apache.lucene.search.BooleanClause.Occur precursorOccur, ValueType type, IndexConfiguration config)
          Combines this query with another.
 XPathQuery combineSpanQueries(XPathQuery precursor, org.apache.lucene.search.BooleanClause.Occur occur, ValueType type, int distance, IndexConfiguration config)
          Combines this query with another, separated by the given distance.
 XPathQuery getBaseQuery()
          A query generated by a predicate expression.
 long getFacts()
           
static XPathQuery getMatchAllQuery(IndexConfiguration indexConfig)
           
 ParseableQuery getParseableQuery()
           
static XPathQuery getQuery(ParseableQuery query, long resultFacts, ValueType valueType, IndexConfiguration indexConfig, org.apache.lucene.search.SortField[] sortFields)
           
 ValueType getResultType()
           
 org.apache.lucene.search.SortField[] getSortFields()
           
 boolean isEmpty()
           
 boolean isFact(int fact)
           
 boolean isImmutable()
           
 boolean isMinimal()
           
 void setBaseQuery(XPathQuery baseQuery)
           
 XPathQuery setFact(int fact, boolean t)
           
 void setSortFields(org.apache.lucene.search.SortField[] sortFields)
           
 void setType(ValueType type)
           
 String toString()
           
 AbstractExpression toXmlNode(String defaultField, IndexConfiguration config)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EXACT

public static final int EXACT
A query is exact iff its xpath expression returns exactly one value per document, and the generated lucene query returns exactly those documents satisfying the xpath expression. EXACT <=> MINIMAL and SINGULAR, and we never use EXACT explicitly

See Also:
Constant Field Values

MINIMAL

public static final int MINIMAL
A query is minimal if it returns all, and only, those documents satisfying the xpath expression. Exact queries are all minimal.

See Also:
Constant Field Values

SINGULAR

public static final int SINGULAR
An expression is singular if it returns a single result for every matching document. An XPathQuery is singular if it was generated from a singular expression, and therefore its expression returns the same number of results as the lucene query.

See Also:
Constant Field Values

BOOLEAN_FALSE

public static final int BOOLEAN_FALSE
A query is boolean_false if its result type is boolean, and the existence of a single query result indicates a 'false()' value

See Also:
Constant Field Values

IGNORABLE

public static final int IGNORABLE
If a query a is ignorable, then combine(a,b) = b unless b is also ignorable, in which case combine(a,b) = a|b

See Also:
Constant Field Values

EMPTY

public static final int EMPTY
queries that match all documents (have no filter) are empty.

See Also:
Constant Field Values

MATCH_ALL

public static final XPathQuery MATCH_ALL
Constructor Detail

XPathQuery

protected XPathQuery(ParseableQuery query,
                     long resultFacts,
                     ValueType valueType,
                     boolean immutable)
Parameters:
query - a Lucene query
resultFacts - a bitmask with interesting facts about this query
valueType - the type of results returned by the xpath expression, as specifically as
immutable - whether this query may be changed - set true for some internal statics like MATCH_ALL can be determined.

XPathQuery

protected XPathQuery(ParseableQuery query,
                     long resultFacts,
                     ValueType valueType)
Method Detail

getSortFields

public org.apache.lucene.search.SortField[] getSortFields()

setSortFields

public void setSortFields(org.apache.lucene.search.SortField[] sortFields)

getQuery

public static XPathQuery getQuery(ParseableQuery query,
                                  long resultFacts,
                                  ValueType valueType,
                                  IndexConfiguration indexConfig,
                                  org.apache.lucene.search.SortField[] sortFields)
Parameters:
query - the query on which the result is based
resultFacts - the facts to use in the new query
valueType - the result type of the new query
indexConfig - the indexer configuration; controls which type of match-all query may be returned
sortFields - the sort fields to record in the query
Returns:
a new query (or an immutable query) based on an existing query with some modifications.

getMatchAllQuery

public static XPathQuery getMatchAllQuery(IndexConfiguration indexConfig)

getParseableQuery

public ParseableQuery getParseableQuery()

isMinimal

public boolean isMinimal()
Returns:
whether it is known that the query will return the minimal set of documents containing the required result value. If false, some documents may be returned that will eventually need to be discarded if they don't match the xpath.

getResultType

public ValueType getResultType()

combineBooleanQueries

public XPathQuery combineBooleanQueries(org.apache.lucene.search.BooleanClause.Occur occur,
                                        XPathQuery precursor,
                                        org.apache.lucene.search.BooleanClause.Occur precursorOccur,
                                        ValueType type,
                                        IndexConfiguration config)
Combines this query with another.

Parameters:
occur - the occurrence specifier for this query
precursor - the other query
precursorOccur - the occurrence specifier for the precursor query
type - the return type of the combined query
config - the index configuration
Returns:
the combined query

combineSpanQueries

public XPathQuery combineSpanQueries(XPathQuery precursor,
                                     org.apache.lucene.search.BooleanClause.Occur occur,
                                     ValueType type,
                                     int distance,
                                     IndexConfiguration config)
Combines this query with another, separated by the given distance. Generates Lucene SpanQuerys, and the constituent queries must be span queries as well.

Parameters:
precursor - the other query
occur - the boolean operator used to combine
type - the return type of the combined query
distance - the distance between the queries
config - the index configuration
Returns:
the combined query

isEmpty

public boolean isEmpty()

toString

public String toString()
Overrides:
toString in class Object

setFact

public XPathQuery setFact(int fact,
                          boolean t)

isFact

public final boolean isFact(int fact)

getFacts

public long getFacts()

setType

public void setType(ValueType type)

isImmutable

public boolean isImmutable()

toXmlNode

public AbstractExpression toXmlNode(String defaultField,
                                    IndexConfiguration config)

getBaseQuery

public XPathQuery getBaseQuery()
A query generated by a predicate expression. Predicates store their base query, rather than their predicated filter query, as the base for path combinations, and also set the filter query to add in as an additional filter.

Returns:
the filter query.

setBaseQuery

public void setBaseQuery(XPathQuery baseQuery)


Copyright © 2013. All Rights Reserved.