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
WILDCARDs 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 theSearchTermas string representation as it can be used inlucene queries, taking asterisks, parentheses and field prefixes into account.static SearchTermgetInstance(String searchInput) Creates a newSearchTermfor 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 newSearchTermfor 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
SearchTerminstance
-
withMatchEndingCondition
Adds a condition to also match text which ends with the search string. Done so by adding anORclause to the final search term containing the search text with anWILDCARDadded 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 anORclause to the final search term containing the search text with anWILDCARDadded to the end.- Returns:
- the modified
SearchTerm
-
asString
Returns theSearchTermas string representation as it can be used inlucene queries, taking asterisks, parentheses and field prefixes into account.- Returns:
- the stringified representation of this
SearchTerm
-