Class SearchTerm
java.lang.Object
ch.tocco.nice2.enterprisesearch.impl.searchbuilder.SearchTerm
SearchTerm
is the representation of a lucene
search term, which can handle parentheses, asterisks
and field prefixes. It can be used to transform an and decorate an input according to the applications needs.
By default, a SearchTerm
will only match the exact search string, except it already has
WILDCARD
s in it. If it should match the search string as beginnings or endings, the corresponding
methods can be used.
Keep in mind that setting withMatchBeginningCondition()
and withMatchEndingCondition()
results in (example OR example* OR *example), not (*example*).-
Method Summary
Modifier and TypeMethodDescriptionasString()
Returns theSearchTerm
as string representation as it can be used inlucene queries
, taking asterisks, parentheses and field prefixes into account.static SearchTerm
getInstance
(String searchInput) Creates a newSearchTerm
for the given input to be used in lucene queries.Adds a condition to also match text which starts with the search string.Adds a condition to also match text which ends with the search string.
-
Method Details
-
getInstance
Creates a newSearchTerm
for the given input to be used in lucene queries. By default, the term is created for exact matches.- Parameters:
searchInput
- the input as retrieved from the application- Returns:
- the
SearchTerm
instance
-
withMatchEndingCondition
Adds a condition to also match text which ends with the search string. Done so by adding anOR
clause to the final search term containing the search text with anWILDCARD
added to the beginning.- Returns:
- the modified
SearchTerm
-
withMatchBeginningCondition
Adds a condition to also match text which starts with the search string. Done so by adding anOR
clause to the final search term containing the search text with anWILDCARD
added to the end.- Returns:
- the modified
SearchTerm
-
asString
Returns theSearchTerm
as string representation as it can be used inlucene queries
, taking asterisks, parentheses and field prefixes into account.- Returns:
- the stringified representation of this
SearchTerm
-