Expressions can be used to create search queries on an Elasticsearch index:
Expression is the base of all expression implementations. In picturesafe-search the following predefined expressions are supported:
|Expression||Description||Comparison operator supported?|
||Expression to match values or query strings on fulltext fields||Yes|
||Expression to match values on fields||Yes|
||Expression to match whole terms on keyword fields||Yes|
||Expression to combine several expressions via a logical operation||-|
||Expression to query ranges between two values||Yes|
||Expression to match a specific day||Yes|
||Expression to query ranges between two days (omitting the time of day)||Yes|
||Expression to match a set of values||-|
||Expression to match null values||-|
||Expression defining a negation of another expression||-|
||Expression to match all documents||-|
FulltextExpression can be used to match values on fulltext fields:
Prerequisite is that a fulltext field has been defined in the field configuration and at least one field has been configured as
ValueExpression can be used to match values on regular fields:
By default, the expression uses the “equals” field comparator. The expression above corresponds to the following:
Further field comparators are explained below.
KeywordExpression should be used to match whole terms on keyword fields:
Keyword fields are not analyzed and therefore will only match on whole terms. For example if the ‘keyword’ field contains the term “this is a test” the
KeywordExpression("keyword", "test") would not match but ` KeywordExpression(“keyword”, “this is a test”)`would match.
OperationExpression can be used to combine several expressions via a logical operation.
In the following example a
FulltextExpression and a
ValueExpression are combined using the
In the same way expressions can be combined using the
Operands of OperationExpressions may be OperationExpressions themselves. In this way complex search expressions can be created:
RangeValueExpression can be used to search for ranges between two values.
DayExpression can be used to match a specific day.
DayRangeExpression can be used to query ranges of days.
InExpression can be used to match a set of values.
IsNullExpression can be used to match null values.
MustNotExpression can be used to define a negation of another expression.
FindAllExpression simply matches all documents in the Elasticsearch index. This can be useful for aggregations to build facets on the whole index data.
The following table gives an overview of the comparison operators which are supported by the
ValueExpression (as described above):
|EQ||equals||token based equality|
|NOT_EQ||not equals||negated token based equality|
|LIKE||like||token based wildcard query - wildcards
|NOT_LIKE||not like||negated token based wildcard query - wildcards
|TERM_STARTS_WITH||term starts with||term based query (only works on keyword fields)|
|TERM_ENDS_WITH||term ends with||term based query (only works on keyword fields)|
|TERM_WILDCARD||term wildcard||term based wildcard query (only works on keyword fields) - wildcards
Note: Term based queries operate on the textual content of (keyword) fields in its entirety, rather than operating on single tokens (e.g. words) as token based queries do.