public interface SearchQueryBuilder extends Refreshable
search-queries
. parse
it or create
your query constructively. The resultingSearchQueryBuilder
queryBuilder = mySearchEngine.getQueryBuilder()
;ComplexSearchQuery
query = queryBuilder.createComplexQuery()
;SearchQuery
subQuery1 = queryBuilder.createTermQuery
(SearchEntry.PROPERTY_TEXT
, "Multimedia*"); query.addRequiredQuery
(subQuery1);SearchQuery
subQuery2 = queryBuilder.createTermQuery
(SearchEntry.PROPERTY_TEXT
, "PHP"); query.addExcludingQuery
(subQuery2);SearchQuery
subQuery3 = queryBuilder.createPhraseQuery
(SearchEntry.PROPERTY_TITLE
, "Enterprise Content Management"); query.addOptionalQuery
(subQuery3);
query
will be the same as if parseStandardQuery(String)
was called with
"+text:Multimedia* -text:PHP title:\"Enterprise Content Management\"".
A SearchQueryBuilder
has to be stateless and thread-safe.Modifier and Type | Method and Description |
---|---|
ComplexSearchQuery |
createComplexQuery()
This method creates a
complex query . |
SearchQuery |
createPhraseQuery(String field,
String phrase)
|
SearchQuery |
createRangeQuery(String field,
String minimum,
String maximum,
boolean minimumInclusive,
boolean maximumInclusive)
This method creates a
SearchQuery for a range of values. |
SearchQuery |
createWordQuery(String field,
String word)
|
SearchQuery |
parseStandardQuery(String query)
This method parses the given
query string in the standard query language of this
specification. |
SearchQuery |
parseStandardQuery(String query,
SearchQueryBuilderOptions options)
This method parses the given
query string in the standard query language of this
specification. |
boolean |
refresh()
This method refreshes the given object.
|
SearchQuery parseStandardQuery(String query) throws SearchException
query
string in the standard query language of this
specification. query
- is the query to parse as string.SearchException
- if the given query
string is illegal and can NOT be parsed.
Implementations should be tolerant and try to avoid this situation.parseStandardQuery(String, SearchQueryBuilderOptions)
SearchQuery parseStandardQuery(String query, SearchQueryBuilderOptions options) throws SearchException
query
string in the standard query language of this
specification. <WHITESPACE> = (' '|'\t'|'\n'|'\r') <WHITESPACES> = (<WHITESPACE>)+ <START_CHAR> = ^(<WHITESPACE>|'+'|'-'|'('|')'|'"'|'\'') <CHAR> = (<START_CHAR>|'+'|'-') <WORD
> = <START_CHAR> (<CHAR>)* <PHRASE
> = '"' (^('"'))* '"' <TO> = ("TO" | "to" | "-") <MIN> = <WORD> <MAX> = <WORD> <RANGE
> = ('{' | '[') <MIN> ' ' <TO> ' ' <MAX> (']' | '}') <MATCH> = (<PHRASE> | <WORD> | <RANGE>) <FIELD> = ('a'-'z'|'A'-'Z')+ <CLAUSE> = ['+'|'-'] [<FIELD> ':'] ( <MATCH> | '(' <QUERY> ')' ) <QUERY
> = <CLAUSE> | <CLAUSE> (<WHITESPACES> <QUERY>)* )
query
- is the query to parse as string.options
- are the SearchQueryBuilderOptions
.SearchException
- if the given query
string is illegal and can NOT be parsed.
Implementations should be tolerant and try to avoid this situation.SearchQuery createPhraseQuery(String field, String phrase)
field
- is the name of the field
to search.phrase
- is the exact phrase to search for.SearchQuery createWordQuery(String field, String word)
field
- is the name of the field
where to search.word
- is the single term or glob pattern (e.g. "moon?i*" to match "moonlight" or "moonride") to
search for.SearchQuery createRangeQuery(String field, String minimum, String maximum, boolean minimumInclusive, boolean maximumInclusive)
SearchQuery
for a range of values.field
- is the name of the field(s)
to match.minimum
- is the minimum or infimum value.maximum
- is the maximum or supremum value.minimumInclusive
- - true
if the minimum
is included and matches,
false
if the minimum
is treated as infimum and only higher values will
match.maximumInclusive
- - true
if the maximum
is included and matches,
false
if the maximum
is treated as supremum and only lower values will
match.SearchQuery
.ComplexSearchQuery createComplexQuery()
complex query
. You can then add sub-queries to this
query with logical operations.boolean refresh()
refresh
in interface Refreshable
true
if something has changed, false
otherwise. If the implementation can not determine the
change it should return true
.Copyright © 2001–2016 mmm-Team. All rights reserved.