Operators

AND Operator

The operator and is used to search for documents in which all of the enumerated arguments are present (regardless their relative position and distance between them in the text).

Syntax

argument_1 and argument_2

Example

"car" and "automobile" and "vehicle"

matches documents in which all the above enumerated arguments are present ("car", "automobile", "vehicle") .

OR Operator

The operator or is used to search for documents in which at least one of the enumerated query arguments is present.

Syntax

argument_1 or argument_2 = argument_1 | argument_2

Example

car or automobile or vehicle = car | automobile | vehicle

matches documents in which at least one of the enumerated query arguments is present ("car", "automobile" or "vehicle").

Note

The or and and operators have equivalent functions orn and andn which are useful when dealing with a query consisting of several arguments, as it makes the expression more succinct.

January or February or November or December = orn(January, February, November, December)

January and February and November and December = andn(January, February, November, December)

XOR Operator

The xor operator is used to search for documents in which only one of the enumerated arguments is present.

Syntax

argument_1 xor argument_2

Example

car xor plane

matches documents in which only one of the enumerated words is present ("car" or "plane"), and it does not match documents in which both words are present or both words are absent.

NOT Operator

The operator not is used to search for documents in which the enumerated arguments are absent.

Syntax

not argument

Example

not car

matches documents in which the word "car" is absent;

not(automobile or car or vehicle)

matches documents in which the words "automobile", "car" and "vehicle" are absent.

Task Example: Find texts about England that do not mention the United Kingdom or other parts of the United Kingdom

In order to exclude texts about Great Britain as a whole country and about other countries forming the United Kingdom users can prohibit the following words and phrases: "United Kingdom", "Great Britain", Scotland, Wales, "Northern Ireland":

England and not orn("United Kingdom", "Great Britain", Scotland, Wales, "Northern Ireland") = England and not ("United Kingdom" or "Great Britain" or Scotland or Wales or "Northern Ireland")

Operator of Difference "/"

The operator "/" (and its equivalent functions difference() or except()) is used to search for documents which contain all of the occurrences of the first argument that do not intersect the occurrences of the second argument.

Syntax

argument_1 / argument_2

Example

term(positive) / orn(amazing, beautiful, helpful) matches documents containing words from the list "positive", except for the words "amazing", "beautiful", "helpful";

case(title) / knownword(geoadministrative) matches documents containing words in title case that are not present in the Geoadministrative Dictionary.

For more information, please see the section Excluding search results.

Operator of Intersection "&"

The operator "&" (and its equivalent functions intersect() and include()) is used to search for documents containing the occurrences of the first argument that intersect the occurrences of the second argument.

Syntax

argument_1 & argument_2

Example

term(list1) & term(list2) matches documents containing both the words from the "list1" and the words from the "list2";

entity(organizations) & entity(geoadministrative) matches documents mentioning organization names that contain geographic objects ("U.S. Congress", "China’s Ministry of Civil Affairs", "Singapore Civil Defense Force", etc.);

case(title) & lemma(noun) = case(title, lemma(noun)) matches documents containing nouns in title case.

Task Example: Find companies whose activity is related to the United States

Users can write the following query to match companies whose name contains words and phrases "United States", "USA", "US" as well as "America" and its derivates (like "American"):

pdl operators 1

The Entity Extraction parent node should be executed for this query to work correctly. For more information, please see section "Entity Extraction Node".

Note

The functions include() and intersect() have some useful features the operator & does not have. For more information, please see the description of include() and intersect() functions.

Operators' Precedence

If a query contains several operators, the order of their performance depends on their precedence, i.e. operators with a higher precedence are performed first.

Operators and their respective precedence level are listed in the following table.

Operator

Precedence

&

5

/

5

not

4

xor

3

and

2

or

1

If a query is made up of several operators with the same precedence level they are executed sequentially left to right.

Example

partofspeech(noun) / vehicle / transport = (partofspeech(noun) / vehicle) / transport

matches documents containing nouns except for the words "vehicle" and "transport".

Users can alter the order of execution determined by operator precedence using parentheses. A subquery within parentheses is fully executed before the remainder of the query.

The order of operator’s execution may influence query results.

Example

sale or rent and property

matches documents containing either the word "sale", or both words "rent" and "property", because the operator and has a higher precedence;

(sale or rent) and property

matches documents containing both the word "property" and either the word "sale" or "rent", because the expression within parentheses has a higher precedence.