Class ProximityQueryNode
- java.lang.Object
-
- org.apache.lucene.queryparser.flexible.core.nodes.QueryNodeImpl
-
- org.apache.lucene.queryparser.flexible.core.nodes.BooleanQueryNode
-
- org.apache.lucene.queryparser.flexible.core.nodes.ProximityQueryNode
-
public class ProximityQueryNode extends BooleanQueryNode
AProximityQueryNode
represents a query where the terms should meet specific distance conditions. (a b c) WITHIN [SENTENCE|PARAGRAPH|NUMBER] [INORDER] ("a" "b" "c") WITHIN [SENTENCE|PARAGRAPH|NUMBER] [INORDER]TODO: Add this to the future standard Lucene parser/processor/builder
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ProximityQueryNode.ProximityType
utility class containing the distance condition and numberstatic class
ProximityQueryNode.Type
Distance condition: PARAGRAPH, SENTENCE, or NUMBER
-
Field Summary
-
Fields inherited from class org.apache.lucene.queryparser.flexible.core.nodes.QueryNodeImpl
PLAINTEXT_FIELD_NAME, toQueryStringIgnoreFields
-
-
Constructor Summary
Constructors Constructor Description ProximityQueryNode(List<QueryNode> clauses, CharSequence field, ProximityQueryNode.Type type, boolean inorder)
ProximityQueryNode(List<QueryNode> clauses, CharSequence field, ProximityQueryNode.Type type, int distance, boolean inorder)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description QueryNode
cloneTree()
Recursive clone the QueryNode tree The tags are not copied to the new tree when you call the cloneTree() methodint
getDistance()
CharSequence
getField()
returns null if the field was not specified in the query stringString
getFieldAsString()
returns null if the field was not specified in the query stringProximityQueryNode.Type
getProximityType()
boolean
isInOrder()
void
setField(CharSequence field)
CharSequence
toQueryString(EscapeQuerySyntax escapeSyntaxParser)
convert to a query string understood by the query parserString
toString()
Every implementation of this class should return pseudo xml like this:-
Methods inherited from class org.apache.lucene.queryparser.flexible.core.nodes.QueryNodeImpl
add, add, allocate, clone, containsTag, getChildren, getParent, getTag, getTagMap, isDefaultField, isLeaf, isRoot, removeChildren, removeFromParent, set, setLeaf, setTag, unsetTag
-
-
-
-
Constructor Detail
-
ProximityQueryNode
public ProximityQueryNode(List<QueryNode> clauses, CharSequence field, ProximityQueryNode.Type type, int distance, boolean inorder)
- Parameters:
clauses
- - QueryNode childrenfield
- - field nametype
- - type of proximity querydistance
- - positive integer that specifies the distanceinorder
- - true, if the tokens should be matched in the order of the clauses
-
ProximityQueryNode
public ProximityQueryNode(List<QueryNode> clauses, CharSequence field, ProximityQueryNode.Type type, boolean inorder)
- Parameters:
clauses
- - QueryNode childrenfield
- - field nametype
- - type of proximity queryinorder
- - true, if the tokens should be matched in the order of the clauses
-
-
Method Detail
-
getProximityType
public ProximityQueryNode.Type getProximityType()
-
toString
public String toString()
Description copied from class:QueryNodeImpl
Every implementation of this class should return pseudo xml like this:For FieldQueryNode: <field start='1' end='2' field='subject' text='foo'/>
- Specified by:
toString
in interfaceQueryNode
- Overrides:
toString
in classBooleanQueryNode
- See Also:
QueryNode.toString()
-
toQueryString
public CharSequence toQueryString(EscapeQuerySyntax escapeSyntaxParser)
Description copied from interface:QueryNode
convert to a query string understood by the query parser- Specified by:
toQueryString
in interfaceQueryNode
- Overrides:
toQueryString
in classBooleanQueryNode
-
cloneTree
public QueryNode cloneTree() throws CloneNotSupportedException
Description copied from interface:QueryNode
Recursive clone the QueryNode tree The tags are not copied to the new tree when you call the cloneTree() method- Specified by:
cloneTree
in interfaceQueryNode
- Overrides:
cloneTree
in classBooleanQueryNode
- Returns:
- the cloned tree
- Throws:
CloneNotSupportedException
-
getDistance
public int getDistance()
- Returns:
- the distance
-
getField
public CharSequence getField()
returns null if the field was not specified in the query string- Returns:
- the field
-
getFieldAsString
public String getFieldAsString()
returns null if the field was not specified in the query string- Returns:
- the field
-
setField
public void setField(CharSequence field)
- Parameters:
field
- the field to set
-
isInOrder
public boolean isInOrder()
- Returns:
- terms must be matched in the specified order
-
-