The FulltextExpression
supports the compact Lucene query string syntax, which allows to specify AND OR NOT conditions and multi-field search within a single query string.
In addition, picturesafe-search offers a preprocessor that allows a less strict, more intuitive query string, especially regarding logical operators and parentheses:
The query string preprocessor is enabled by default. Settings can be changed in elasticsearch.properties:
# --- Query string preprocessor ---
## Enable preprocessing of fulltext query strings (will be enabled per default when empty)
#elasticsearch.querystring_preprocessor.enabled=true
## Enable adding brackets automatically in preprocessor (will be enabled per default when empty)
#elasticsearch.querystring_preprocessor.auto_bracket=true
## Enable adding missing operators automatically in preprocessor (will be enabled per default when empty)
#elasticsearch.querystring_preprocessor.insert_missing_operators=true
## Token delimiters in preprocessor (will be set to the following default value when empty)
#elasticsearch.querystring_preprocessor.token_delimiters:, "(){}[]:=\\/^~
## Synonyms for the operator AND (separated by blank, will be set to 'and und & +' when empty)
#elasticsearch.querystring_preprocessor.synonyms.AND=and und & +
## Synonyms for the operator OR (separated by blank, will be set to 'or oder | ,' when empty)
#elasticsearch.querystring_preprocessor.synonyms.OR=or oder | ,
## Synonyms for the operator NOT (separated by blank, will be set to 'not nicht -' when empty)
#elasticsearch.querystring_preprocessor.synonyms.NOT=not nicht -
The following examples use different synonyms for the AND operator, but result in the same logical fulltext expression:
The following examples use different synonyms for the OR operator, but result in the same logical fulltext expression:
The following examples use different synonyms for the NOT operator, but result in the same logical fulltext expression:
The familiar boolean operators AND, OR and NOT are also supported by the Elasticsearch query string syntax, but beware that they do not honor the usual precedence rules (so Elasticsearch recommends to use parentheses whenever multiple operators are used together).
For this reason, picturesafe-search extends parentheses internally by default when using logical operators.
The following logical expressions have the same precedence:
A query string syntax sample can be found here.
with by the picturesafe-search community
Code licensed Apache License 2.0 Documentation licensed CC-BY-4.0