@Immutable public class CompareStringQuery extends CompareQuery<String>
Query
implementation that is used to apply a Comparison
constraint against a string field. This query
implementation works by using the weight and Weight.scorer(LeafReaderContext)
scorer} of the wrapped query
to score (and return) only those documents with string fields that satisfy the constraint.CompareQuery.Evaluator<ValueType>
ConstantScoreWeightQuery.ConstantWeight, ConstantScoreWeightQuery.ConstantWeightScorer
Modifier and Type | Field and Description |
---|---|
protected static CompareQuery.Evaluator<String> |
EQUAL_TO |
protected static CompareQuery.Evaluator<String> |
IS_GREATER_THAN |
protected static CompareQuery.Evaluator<String> |
IS_GREATER_THAN_OR_EQUAL_TO |
protected static CompareQuery.Evaluator<String> |
IS_LESS_THAN |
protected static CompareQuery.Evaluator<String> |
IS_LESS_THAN_OR_EQUAL_TO |
caseOperation, constraintValue, evaluator, stringFactory, valueTypeFactory
Modifier | Constructor and Description |
---|---|
protected |
CompareStringQuery(String fieldName,
String constraintValue,
ValueFactory<String> valueFactory,
ValueFactory<String> stringFactory,
CompareQuery.Evaluator<String> evaluator,
CaseOperations.CaseOperation caseOperation)
Construct a
Query implementation that scores nodes according to the supplied comparator. |
Modifier and Type | Method and Description |
---|---|
org.apache.lucene.search.Query |
clone() |
static org.apache.lucene.search.Query |
createQueryForNodesWithFieldEqualTo(String constraintValue,
String fieldName,
ValueFactories factories,
CaseOperations.CaseOperation caseOperation)
Construct a
Query implementation that scores documents with a string field value that is equal to the supplied
constraint value. |
static CompareStringQuery |
createQueryForNodesWithFieldGreaterThan(String constraintValue,
String fieldName,
ValueFactories factories,
CaseOperations.CaseOperation caseOperation)
Construct a
Query implementation that scores documents with a string field value that is greater than the supplied
constraint value. |
static CompareStringQuery |
createQueryForNodesWithFieldGreaterThanOrEqualTo(String constraintValue,
String fieldName,
ValueFactories factories,
CaseOperations.CaseOperation caseOperation)
Construct a
Query implementation that scores documents with a string field value that is greater than or equal to
the supplied constraint value. |
static CompareStringQuery |
createQueryForNodesWithFieldLessThan(String constraintValue,
String fieldName,
ValueFactories factories,
CaseOperations.CaseOperation caseOperation)
Construct a
Query implementation that scores documents with a string field value that is less than the supplied
constraint value. |
static CompareStringQuery |
createQueryForNodesWithFieldLessThanOrEqualTo(String constraintValue,
String fieldName,
ValueFactories factories,
CaseOperations.CaseOperation caseOperation)
Construct a
Query implementation that scores documents with a string field value that is less than or equal to the
supplied constraint value. |
static org.apache.lucene.search.Query |
createQueryForNodesWithFieldLike(String likeExpression,
String fieldName,
ValueFactories factories,
CaseOperations.CaseOperation caseOperation)
Construct a
Query implementation that scores documents with a string field value that is LIKE the supplied
constraint value, where the LIKE expression contains the SQL wildcard characters '%' and '_' or the regular expression
wildcard characters '*' and '?'. |
protected static boolean |
hasWildcardCharacters(String expression) |
static String |
toRegularExpression(String likeExpression)
Convert the JCR like expression to a regular expression.
|
protected static String |
toWildcardExpression(String likeExpression)
Convert the JCR like expression to a Lucene wildcard expression.
|
areValid, toString
createWeight, field
protected static final CompareQuery.Evaluator<String> EQUAL_TO
protected static final CompareQuery.Evaluator<String> IS_LESS_THAN
protected static final CompareQuery.Evaluator<String> IS_LESS_THAN_OR_EQUAL_TO
protected static final CompareQuery.Evaluator<String> IS_GREATER_THAN
protected static final CompareQuery.Evaluator<String> IS_GREATER_THAN_OR_EQUAL_TO
protected CompareStringQuery(String fieldName, String constraintValue, ValueFactory<String> valueFactory, ValueFactory<String> stringFactory, CompareQuery.Evaluator<String> evaluator, CaseOperations.CaseOperation caseOperation)
Query
implementation that scores nodes according to the supplied comparator.fieldName
- the name of the document field containing the value; may not be nullconstraintValue
- the constraint value; may not be nullvalueFactory
- the value factory that can be used during the scoring; may not be nullstringFactory
- the string factory that can be used during the scoring; may not be nullevaluator
- the CompareQuery.Evaluator
implementation that returns whether the node path satisfies the
constraint; may not be nullpublic static org.apache.lucene.search.Query createQueryForNodesWithFieldEqualTo(String constraintValue, String fieldName, ValueFactories factories, CaseOperations.CaseOperation caseOperation)
Query
implementation that scores documents with a string field value that is equal to the supplied
constraint value.constraintValue
- the constraint value; may not be nullfieldName
- the name of the document field containing the value; may not be nullfactories
- the value factories that can be used during the scoring; may not be nullcaseOperation
- the operation that should be performed on the indexed values before the constraint value is being
evaluated; may not be nullpublic static CompareStringQuery createQueryForNodesWithFieldGreaterThan(String constraintValue, String fieldName, ValueFactories factories, CaseOperations.CaseOperation caseOperation)
Query
implementation that scores documents with a string field value that is greater than the supplied
constraint value.constraintValue
- the constraint value; may not be nullfieldName
- the name of the document field containing the value; may not be nullfactories
- the value factories that can be used during the scoring; may not be nullcaseOperation
- the operation that should be performed on the indexed values before the constraint value is being
evaluated; may not be nullpublic static CompareStringQuery createQueryForNodesWithFieldGreaterThanOrEqualTo(String constraintValue, String fieldName, ValueFactories factories, CaseOperations.CaseOperation caseOperation)
Query
implementation that scores documents with a string field value that is greater than or equal to
the supplied constraint value.constraintValue
- the constraint value; may not be nullfieldName
- the name of the document field containing the value; may not be nullfactories
- the value factories that can be used during the scoring; may not be nullcaseOperation
- the operation that should be performed on the indexed values before the constraint value is being
evaluated; may not be nullpublic static CompareStringQuery createQueryForNodesWithFieldLessThan(String constraintValue, String fieldName, ValueFactories factories, CaseOperations.CaseOperation caseOperation)
Query
implementation that scores documents with a string field value that is less than the supplied
constraint value.constraintValue
- the constraint value; may not be nullfieldName
- the name of the document field containing the value; may not be nullfactories
- the value factories that can be used during the scoring; may not be nullcaseOperation
- the operation that should be performed on the indexed values before the constraint value is being
evaluated; may not be nullpublic static CompareStringQuery createQueryForNodesWithFieldLessThanOrEqualTo(String constraintValue, String fieldName, ValueFactories factories, CaseOperations.CaseOperation caseOperation)
Query
implementation that scores documents with a string field value that is less than or equal to the
supplied constraint value.constraintValue
- the constraint value; may not be nullfieldName
- the name of the document field containing the value; may not be nullfactories
- the value factories that can be used during the scoring; may not be nullcaseOperation
- the operation that should be performed on the indexed values before the constraint value is being
evaluated; may not be nullprotected static boolean hasWildcardCharacters(String expression)
public static org.apache.lucene.search.Query createQueryForNodesWithFieldLike(String likeExpression, String fieldName, ValueFactories factories, CaseOperations.CaseOperation caseOperation)
Query
implementation that scores documents with a string field value that is LIKE the supplied
constraint value, where the LIKE expression contains the SQL wildcard characters '%' and '_' or the regular expression
wildcard characters '*' and '?'.likeExpression
- the LIKE expression; may not be nullfieldName
- the name of the document field containing the value; may not be nullfactories
- the value factories that can be used during the scoring; may not be nullcaseOperation
- the operation that should be performed on the indexed values before the constraint value is being
evaluated; may not be nullprotected static String toWildcardExpression(String likeExpression)
likeExpression
- the like expression; may not be nullpublic static String toRegularExpression(String likeExpression)
likeExpression
- the like expression; may not be nullpublic org.apache.lucene.search.Query clone()
clone
in class org.apache.lucene.search.Query
Copyright © 2008–2016 JBoss, a division of Red Hat. All rights reserved.