Complex Search Queries

Complex search queries contain multiple operators and/or wild cards or other search methods (fuzzy search, field search, excluded lists).

Examples

Example of query

Results

car AND (IN <fieldname> {rental})

Files containing 'car' and a specified field with the value 'rental' are selected.

1 of {o* - {other, often, out}, p* - {process, procedure}, const* - {constitution, constitute, constant}}

Files containing at least one word starting with 'o', 'p' or 'const'. The files may contain the words 'other', 'often', 'out', 'process', 'procedure', 'constitution', 'constitute', or 'constant', but these words will not be highlighted.

2 of {(common law), (tort and (chief engineer) and due diligence), 1 of {breach, litig*, process, damag*, liability}}

Files containing at least two results from three search queries (query 1: common law, query 2: tort and chief engineer and due diligence, query 3: 1 of breach, litig*, process, damag*, liability). For example, the result might be:

'common law', 'breach'

or

'tort', 'chief engineer', 'due diligence', 'damage'

contract and 2 of {(bidding or rate or placement or offer or pro rata or exclu* clause), (breach or litigation or arbitration or damag*), (honor* or due diligence), (limited liabil* or warrant* or liquid*)}

Files containing the word 'contract' and at least two results from three search queries. For example, the result might be:

'contract', 'bidding', 'offer', 'breach'

*valu* w/10 (*book* or mark* or public*) w/20 (wrong or *correct)

The result might be:

'The right (and wrong) way to market a book. The value of a book...'

Where 'wrong', 'market', 'book' and 'value' will be highlighted.

(sell* TO book* {(Donoghue or Ferris or Mister or Moyes)}) AND (2017 or 2018)

The result might be:

'In 2018, we are selling the new thriller from Mister in our bookstore.'

Where 'Mister' and '2018' will be highlighted.

u.s.

No search results. A dot followed by a space is by default recognized as a separator by the tokenizer; The last '.' will not be part of the token. So, the abbreviation u.s. will not be found, nor will u.s be found. To find the abbreviation u.s., search for 'u.s'


Hyphenated Text

Example 1

Text: 'some text left-right apple orange pear left-apple-right'

Example of query

Results

left TO right {apple}

We expect just 'left-apple-right' to be found, however, 'apple' following 'left-right' is also found. This is because both 'left' and 'right' tokens in 'left-right' text are the same token and so are the 'left' and 'right' tokens in 'left-apple-right' text. This is because hyphenated tokens get the same token id during tokenization process. Since left and right query tokens are the same, we proceed to move the right query to the next occurrence and match sub query. Thus, the extra 'apple' word is matched.

EOP to EOP {apple}

Here, token ids for left and right query will be same since it is the same query, and we indeed want to match everything between the current token of EOP and the next token of EOP.


Example 2

Text: 'fresh apple-banana pie'

Where 'fresh' has position 1, 'apple' has position 2 and 'banana' has position 2 (since they are combined with a hyphen), 'pie' has position 3.

Example of query

Results

Results Explained

NOT(apple) banana pie

fresh apple-banana pie

 

First the term 'pie' is matched at position 3, then at position 2 'banana' is matched, next, NOT(apple) is matched with 'fresh' at position 1. In this example, 'apple' will be skipped.

apple NOT(banana) pie

no results

First the term 'pie' is matched at position 3, then at position 2 we will first find 'banana', but that does not match the query NOT(banana). Therefore, no results are returned.


Note 1: Since you may not know upfront if a combination of words is hyphenated, it is advised to try different combinations of search queries when you suspect a hyphenated word might be part of the results.

Note 2: If a word or combination of words you are searching for contains a hyphen, that word will often be found, even if you did not include a hyphen in your search query. For example, when you search for 'email' or 'e mail', it will also find 'e-mail'. However, 'e mail' will not find 'email' or the other way around ('email' will not find 'e mail').


Complex Search Queries using the NOT Operator

The processing rules for the NOT operator differ depending on the context in which it is used. Nevertheless, the NOT operator can be used several times in both a Boolean and positional context in a single query. For example, 'NOT(green AND NOT black) tea', in which the first NOT is used in a positional context and the second NOT is used in a Boolean context.

Syntax Examples

Syntax

Semantics

Recommended Use

left_query AND NOT right_query

(left_query) AND NOT (right_query)

Where NOT is used in combination with AND (Boolean context) and connects any query, such as word(s), wild card or regular expression (regex) query, sequence query, etc.

For clarity, the queries can be placed between brackets. Please be aware that sometimes using brackets can influence the search results.

The combination of AND with NOT is often used to refine search results after a previous query.

Finds documents where the left_query is present and the right_query is not.

left_query OR NOT right_query

(left_query) OR NOT (right_query)

Where NOT is used in combination with OR (Boolean context) and connects any query, such as word(s), wild card or regular expression (regex) query, sequence query, etc.

Finds documents where the left_query is present and/or where the right_query is not present.

NOT (left_query) AND NOT (right_query)

 

Where both the first stand-alone NOT and the second NOT used in combination with AND are used in a Boolean context .

Finds all documents where neither the left_query nor the right_query occur.

NOT (left_query) OR NOT (right_query)

Where both the first stand-alone NOT and the second NOT used in combination with OR are used in a Boolean context .

Finds documents where at least one of the queries is not present.

NOT (first_query second_query n_query)

Where NOT is used stand-alone (Boolean context) and is connected to a sequence (several terms) at one position (through parenthesis).

Note: 'NOT(a b c)' is not similar to 'NOT(a) NOT(b) NOT(c)', which is an ambiguous search query and will generate an error.

This query will narrow down your result set. Used when you want to find all documents where a specific word, phrase or results from specific queries are not present.

NOT(first_query) second_query n_query

Where NOT, used in a positional context , excludes any query placed in a sequence. NOT can be placed anywhere in a sequence.

Used when you want to specifically omit (at a specific position in the sequence) a word or sequence of words usually connected with the other queries.

first_query NOT(second_query) n_query

Where NOT, used in a positional context , excludes any query placed in a sequence. NOT can be placed anywhere in a sequence.

 

left_query TO right_query {sub_query}

NOT is used in a positional context, in the sub query of a positional TO query. See TO Operator.         
Where left_query and right_query can be a word query or a sequence query without negated sub-queries and sub_query can be any valid query. For example, {word NOT word}, {NOT word} or {word AND/OR NOT word}.

Used when you want to specifically omit a word or sequence of words often related to the words found between the left_ and right_query.

NOT(left_query AND NOT right_query) query

Where the first NOT is used in a positional context and the second NOT is used in a Boolean context .

 

NOT(NOT left_query AND NOT right_query)

is equal to:

left_query OR right_query

Where all NOT operators are used in a Boolean context .

           

NOT(NOT NOT term AND NOT term)

incorrect syntax

Will result in an error because of nested NOT operator in a Boolean context in sub query 'NOT NOT term'.

 

NOT(first_query) NOT(second_query) NOT(third_query)

incorrect syntax

Search query will generate an error.

Too many combinations are possible, making the search query pointless.


Query Examples

Example of query

Results

Results Explained

NOT apple AND NOT orange

All documents that contain neither 'apple' nor 'orange'.

 

apple AND NOT pear

Only files that contain the term 'apple'.

 

apple OR NOT pear

Files that contain the term 'apple' (the term 'pear' can be present in the file, but not highlighted) and files that do not contain the term 'pear' (no hits, since 'apple' is not present either).

NOT(green AND NOT black) tea

Will find 'black tea', 'white tea' and just 'tea'.

Because it was double negated, it will find black tea.

NOT(green AND black) tea

Will find 'white tea', 'warm tea', just 'tea'. Will not find 'green tea' and 'black tea'.

 

leaf AND NOT tree

Only documents where 'leaf' is present.

Narrow your search and exclude terms often connected to your search.

used cars AND NOT cars

no results

No error generated, it is syntactically correct, but semantically meaningless.

cars AND NOT used cars

Will find 'cars', but not 'used cars'.

 

apple AND NOT(orange or pear)

Will find documents with only 'apple' in it, but not documents with 'apple' and 'orange' or 'pear'.

 

apple OR NOT(orange pear)

Will find 'apple'.

And all documents that do not contain the phrase 'orange pear'.

 

used cars OR NOT cars

Will find documents with 'used cars'. Documents with only 'cars' will not be found.

 

cars OR NOT used cars

Will find documents with 'cars'. Also, every word in front of 'cars' will be found/ highlighted (except when that word is 'used').

These documents can also contain the phrase 'used cars', but 'used' will not be highlighted.

 

NOT (NOT(apple))

no results, error

Nested NOT query is not allowed.

NOT NOT apple

no results, error

Nested NOT query is not allowed.

NOT (NOT apple)

no results, error

Nested NOT query is not allowed.

apple NOT(orange) pear

matches sequence 'apple <anything but orange> pear'.

 

apple NOT(orange OR pear)

matches sequence 'apple <anything but orange and pear>'

NOT combined with a Boolean OR query.

apple NOT(orange AND pear)

matches sequence 'apple <anything but orange and pear>'

NOT combined with a Boolean AND query.

warm NOT(green) tea

warm black tea, warm white tea, warm warm tea, warm [any other word than green] tea, etc.

 

apple TO orange {pear NOT yellow}

matches text where word 'orange' follows 'apple' and sequence 'pear <anything but yellow>' in between (order is important).

 

apple TO orange {pear AND NOT yellow}

matches documents with 'orange' following 'apple' and 'pear' and something not 'yellow' in between the two terms (order not important).

 

NOT apple TO orange {pear}

no results, error

'NOT apple' is a NOT query, which is not allowed in a positional filter TO query.

apple TO (orange NOT pear) {yellow}

no results, error

'orange NOT pear' is a sequence query with a negated sub-query, which is not allowed in a positional filter TO query.


Boolean Context: Negated Sequence

Query matching at the beginning of a document

If a sequence query contains a number of negated terms followed by a positive term that matches the first token in a given text, the first single token will be matched. Consider the text 'apple pie smells good' and a sequence query 'not(banana) not(orange) apple'. The query matches the first word, 'apple', in the text above.

Query matching at the end of a document

If a sequence query contains a number of trailing negated terms preceded by a positive term that matches the last token in a given text, the last token will be matched. Consider the text 'apple pie smells good' and a sequence query 'good not(red) not(blue)'. The query matches the last word, 'good', in the text above.