Filtering operators - Fluid Topics

AFS Taruqa

Category
Technical Notes
Audience
public

It is possible to use the following prefix operators to overwrite the default filtering role of a term or sequence: - "-" to exclude terms - "+" to make terms mandatory - "?" to make terms optional

A character matching one of these operators in the query field becomes an operator if: - It is not in an exact search sequence - It is preceded by a whitespace (or is the first character in the query) - It is followed without space by either an alphanumeric character or the starting double quote of an exact search sequence.

Otherwise, it remains a regular token and in most cases is an ignored term.

For example:

The reply to the following query only includes documents containing the term user but not containing the term guide (or any term with the same stemmed form, for example guides).

{"terms": {"query": "user -guide"}}

The reply to the following query will include all documents in the corpus except those containing "user guide".

{"terms": {"query": "-\"user guide\""}}

The reply to the following query will include documents containing any term with the same stemmed form as "guide" but not the sequence "user guide":

{"terms": {"query": "guide -\"user guide\""}}

The reply to the following query will include documents those containing "user guide", as well as those containing "simple" (even if they do not contain "user guide").

{"terms": {"query": "simple ?\"user guide\""}}

The reply to the following query will include documents containing both "user guide" and any term with the same stemmed form as "installation":

{"terms": {"query": "\"user guide\" +installation"}}

In the following cases, the characters are not used as operators: - Not preceded by a space.

{"terms": {"query": "high-tech"}}
{"terms": {"query": "C++ compiler"}}
  • Not adjacent to a term or the start of an exact search sequence.

    {"terms": {"query": "Where is waldo ? Not here"}}
    
  • In an exact search sequence.

    {"terms": {"query": "\"grep -v -i\""}}
    
  • Not adjacent to a term or the start of an exact search sequence (first "-") or not preceded by a space (second "-")

    {"terms": {"query": "grep --help"}}