Class PhraseNear
- java.lang.Object
-
- com.attivio.sdk.search.query.phrase.Phrase
-
- com.attivio.sdk.search.query.phrase.PhraseNear
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable
public final class PhraseNear extends Phrase
Phrase for matching terms that are proximal to each other.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.attivio.sdk.search.query.phrase.Phrase
Phrase.Parameter
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_MINIMUMDefault minimum.static intDEFAULT_NEAR_DISTANCEDefault distance for near/onear phrases.static intMAX_DISTANCEMaximum distance allowed.static intMIN_DISTANCEMinimum distance allowed.static intREQUIRE_ALL_DISTANCEDistance for require all phrases.protected java.util.List<Phrase>termsList of terms for matching.-
Fields inherited from class com.attivio.sdk.search.query.phrase.Phrase
boost, parameters
-
-
Constructor Summary
Constructors Constructor Description PhraseNear()ConstructorPhraseNear(boolean ordered, int distance)ConstructorPhraseNear(Phrase... terms)ConstructorPhraseNear(Phrase[] terms, int offset, int length)ConstructorPhraseNear(java.lang.String... terms)ConstructorPhraseNear(java.util.List<Phrase> terms)Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddTerm(Phrase term)Addtermto this phrase.voidaddTerm(java.lang.String term)Add aSearchTermto this phrase.voidaddTerms(Phrase[] terms)Addtermsto this phrase.voidaddTerms(Phrase[] terms, int offset, int length)AddvoidaddTerms(java.util.List<Phrase> terms)Addtermsto this phrase.PhraseNearappend(Phrase term)PhraseNearappend(Phrase... terms)PhraseNearappend(java.lang.String term)PhraseNearappend(java.lang.String... terms)PhraseNearclone()protected Phraseclone(Phrase[] terms, int length)Clone to facilitate rewrite().booleanequals(java.lang.Object other)intgetDistance()Get the maximum amount of distance allowed between the first and last matching term.intgetEndOffset()Get the end offset (0 indexed, exclusive) for this term in the original query string.intgetMinimum()Get the minimum number of sub phrases that are required to produce a match.intgetStartOffset()Get the start offset (0 indexed, inclusive) for this term in the original query string.java.util.List<Phrase>getTerms()Get the terms for this phrase.inthashCode()booleanisExactPhrase()Returns true if this phrase requires all terms to be adjacent and in order.booleanisOrdered()Get if terms in phrase must be in order.booleanisRequireAll()Returns true if this phrase is a "require all" phrase.static PhraseNearnear()Create a near (with default distance).static PhraseNearnear(Phrase... terms)Create a near (with default distance).static PhraseNearnear(Phrase[] terms, int offset, int length)Create a near (with default distance).static PhraseNearnear(Phrase a, Phrase b, int distance)Create a near between 2 terms with specified distance.static PhraseNearnear(java.lang.String... terms)Create a near (with default distance).static PhraseNearonear()Create an onear (with default distance).static PhraseNearonear(Phrase... terms)Create an onear (with default distance).static PhraseNearonear(Phrase[] terms, int offset, int length)Create an onear (with default distance).static PhraseNearonear(Phrase a, Phrase b, int distance)Create an onear between 2 terms with specified distance.static PhraseNearonear(java.lang.String... terms)Create an onear (with default distance).static PhraseNearphrase()Create an exact phrase.static PhraseNearphrase(Phrase... terms)Create an exact phrase.static PhraseNearphrase(Phrase[] terms, int offset, int length)Create an exact phrase.static PhraseNearphrase(java.lang.String... terms)Create an exact phrase.static PhraseNearrequireAll()Create a require all.static PhraseNearrequireAll(Phrase... terms)Create a require all.static PhraseNearrequireAll(java.lang.String... terms)Create a require all.Phraserewrite(PhraseHandler handler)Recursively rewrite this phrase usinghandler.PhraserewriteChildren(PhraseHandler handler)Rewrite any children of this phrase usinghandler.voidsetDistance(int value)Set the maximum amount of distance allowed between the first and last matching term.voidsetMinimum(int value)Set the minimum number of sub phrases that are required to produce a match.voidsetOrdered(boolean value)Set if terms in phrase must be in order.voidsetParameter(java.lang.String name, java.lang.Object value)Set parameternametovalue.voidsetTerms(Phrase... args)Set the terms for this phrase.voidsetTerms(java.lang.String... args)Set the terms for this phrase.voidsetTerms(java.util.List<Phrase> value)Set the terms for this phrase.intsize()Get the number of terms in this phrase.voidtoString(java.lang.StringBuilder buffer, boolean compact)Appends the string representation of this query tobuffer.-
Methods inherited from class com.attivio.sdk.search.query.phrase.Phrase
containsParameters, containsParameters, copyParameters, getBoost, getParameter, getParameter, getParameter, getParameter, getParameterInternal, isMatchAll, parameters, parseIntParameter, removeParameter, setBoost, setParameters, toArray, toString, toString
-
-
-
-
Field Detail
-
DEFAULT_MINIMUM
public static final int DEFAULT_MINIMUM
Default minimum.- See Also:
- Constant Field Values
-
DEFAULT_NEAR_DISTANCE
public static final int DEFAULT_NEAR_DISTANCE
Default distance for near/onear phrases.- See Also:
- Constant Field Values
-
REQUIRE_ALL_DISTANCE
public static final int REQUIRE_ALL_DISTANCE
Distance for require all phrases.Require all phrases place no restriction on distance between terms in phrase.
- See Also:
- Constant Field Values
-
MAX_DISTANCE
public static final int MAX_DISTANCE
Maximum distance allowed.Distances equal to are larger than this will be treated as a require all phrase.
- See Also:
- Constant Field Values
-
MIN_DISTANCE
public static final int MIN_DISTANCE
Minimum distance allowed.Distances equal to or less than this will be treated as a require all phrase.
- See Also:
- Constant Field Values
-
terms
protected java.util.List<Phrase> terms
List of terms for matching.
-
-
Constructor Detail
-
PhraseNear
public PhraseNear()
Constructor
-
PhraseNear
public PhraseNear(boolean ordered, int distance)Constructor
-
PhraseNear
public PhraseNear(java.lang.String... terms)
Constructor
-
PhraseNear
public PhraseNear(Phrase... terms)
Constructor
-
PhraseNear
public PhraseNear(Phrase[] terms, int offset, int length)
Constructor
-
PhraseNear
public PhraseNear(java.util.List<Phrase> terms)
Constructor
-
-
Method Detail
-
setParameter
public void setParameter(java.lang.String name, java.lang.Object value)Set parameternametovalue.NOTE:
nameis case insensitive.- Overrides:
setParameterin classPhrase
-
isOrdered
public boolean isOrdered()
Get if terms in phrase must be in order.
-
setOrdered
public void setOrdered(boolean value)
Set if terms in phrase must be in order.
-
getDistance
public int getDistance()
Get the maximum amount of distance allowed between the first and last matching term.If this is 0, then all terms in this phrase must be adjacent to each other.
-
setDistance
public void setDistance(int value)
Set the maximum amount of distance allowed between the first and last matching term.
-
getMinimum
public int getMinimum()
Get the minimum number of sub phrases that are required to produce a match.If this is 0, then all sub phrases are required for a match.
NOTE: minimum is not supported for ordered phrases.
-
setMinimum
public void setMinimum(int value)
Set the minimum number of sub phrases that are required to produce a match.If this is 0, then all sub phrases are required for a match.
NOTE: minimum is not supported for ordered phrases.
-
isExactPhrase
public boolean isExactPhrase()
Returns true if this phrase requires all terms to be adjacent and in order.
-
isRequireAll
public boolean isRequireAll()
Returns true if this phrase is a "require all" phrase.Require all phrases place no restriction on ordering of terms or distance between terms.
-
append
public PhraseNear append(java.lang.String term)
-
append
public PhraseNear append(java.lang.String... terms)
-
append
public PhraseNear append(Phrase term)
-
append
public PhraseNear append(Phrase... terms)
-
hashCode
public int hashCode()
-
equals
public boolean equals(java.lang.Object other)
-
clone
public PhraseNear clone()
-
toString
public void toString(java.lang.StringBuilder buffer, boolean compact)Appends the string representation of this query tobuffer.
-
requireAll
public static PhraseNear requireAll()
Create a require all.
-
requireAll
public static PhraseNear requireAll(Phrase... terms)
Create a require all.
-
requireAll
public static PhraseNear requireAll(java.lang.String... terms)
Create a require all.
-
phrase
public static PhraseNear phrase()
Create an exact phrase.
-
phrase
public static PhraseNear phrase(Phrase... terms)
Create an exact phrase.
-
phrase
public static PhraseNear phrase(Phrase[] terms, int offset, int length)
Create an exact phrase.
-
phrase
public static PhraseNear phrase(java.lang.String... terms)
Create an exact phrase.
-
near
public static PhraseNear near()
Create a near (with default distance).
-
near
public static PhraseNear near(Phrase... terms)
Create a near (with default distance).
-
near
public static PhraseNear near(Phrase[] terms, int offset, int length)
Create a near (with default distance).
-
near
public static PhraseNear near(Phrase a, Phrase b, int distance)
Create a near between 2 terms with specified distance.
-
near
public static PhraseNear near(java.lang.String... terms)
Create a near (with default distance).
-
onear
public static PhraseNear onear()
Create an onear (with default distance).
-
onear
public static PhraseNear onear(Phrase... terms)
Create an onear (with default distance).
-
onear
public static PhraseNear onear(Phrase[] terms, int offset, int length)
Create an onear (with default distance).
-
onear
public static PhraseNear onear(Phrase a, Phrase b, int distance)
Create an onear between 2 terms with specified distance.
-
onear
public static PhraseNear onear(java.lang.String... terms)
Create an onear (with default distance).
-
getStartOffset
public int getStartOffset()
Description copied from class:PhraseGet the start offset (0 indexed, inclusive) for this term in the original query string.This value is set during parsing and indicates the start offset into the original query string that this term represents. In general, offsets should not be set/modified by query transformers and it is recommended that start and end offsets are set to zero when cloning.
NOTE: if
Phrase.getStartOffset()==Phrase.getEndOffset(), this indicates that the term did not come from a parsed query string.- Specified by:
getStartOffsetin classPhrase
-
getEndOffset
public int getEndOffset()
Description copied from class:PhraseGet the end offset (0 indexed, exclusive) for this term in the original query string.This value is set during parsing and indicates the end offset of the original query string that this term represents. In general, offsets should not be set/modified by query transformers and it is recommended that start and end offsets are set to zero when cloning.
NOTE: if
Phrase.getStartOffset()==Phrase.getEndOffset(), this indicates that the term did not come from a parsed query string.- Specified by:
getEndOffsetin classPhrase
-
size
public int size()
Get the number of terms in this phrase.
-
getTerms
public java.util.List<Phrase> getTerms()
Get the terms for this phrase.
-
setTerms
public void setTerms(java.util.List<Phrase> value)
Set the terms for this phrase.
-
setTerms
public void setTerms(java.lang.String... args)
Set the terms for this phrase.
-
setTerms
public void setTerms(Phrase... args)
Set the terms for this phrase.
-
addTerm
public void addTerm(java.lang.String term)
Add aSearchTermto this phrase.
-
addTerm
public void addTerm(Phrase term)
Addtermto this phrase.
-
addTerms
public void addTerms(Phrase[] terms)
Addtermsto this phrase.
-
addTerms
public void addTerms(Phrase[] terms, int offset, int length)
Addlength terms from
termsstarting atoffset.
-
addTerms
public void addTerms(java.util.List<Phrase> terms)
Addtermsto this phrase.
-
rewrite
public Phrase rewrite(PhraseHandler handler)
Recursively rewrite this phrase usinghandler.NOTE: If a phrase has any children, the phrase itself will be passed to
handlerfirst, prior to its children. Ifhandlerreturns a new phrase, its children will not be traversed automatically.
-
rewriteChildren
public Phrase rewriteChildren(PhraseHandler handler)
Description copied from class:PhraseRewrite any children of this phrase usinghandler.Returns the modified phrase, which may be
nullif all children were removed byhandler.This method may have no effect if this
Phraserepresents a leaf in the tree.NOTE: child phrases are not recursively traversed.
- Specified by:
rewriteChildrenin classPhrase
-
-