Comparison Operators
DQL supports many of the standard comparison operators found in most languages.
Contains (Colon)
The colon/contains operator tests for equality between a field and its value. The contains operator is not case-sensitive. To perform a case-sensitive search, see the strict
operator.
If the value is a double-quoted string, the entire string is treated as a single query. If the search string has multiple words, the query will allow for up to one missing word between each consecutive pair of words, and an unlimited number of surrounding words.
For example: To find all organizations that have “Facebook” within any one of their known aliases, including Facebook, Facebook Advertising, etc.:
type:Organization name:"Facebook"
This will do a “contains” search against all names (allNames
) associated with an entity.
To narrow the results, you might use the Corporation
sub-type and the strict
operator with the formal company name. For example:
type:Organization strict:name:"Microsoft Corporation"
Try Regex for a much more flexible search operator
String fields are tokenized for efficient search. In some cases, your substring in a
contains
operator may not work. For these cases, try the Regex Operator.
Not Equals
The Not Equals operator !=
specifies that entities matching a particular field value should be omitted from the results.
This query returns all Organization entities in San Francisco, except for those companies whose name is "San Francisco State University":
This query returns all Organizations located in the city of San Francisco that are not local businesses:
type:Organization location.city.name:"San Francisco" types!="LocalBusiness"
The Not Equals operator can also be used with the regex operator. This query returns all Organizations whose name does not begin with "University":
type:Organization re:name!="University.*"
To exclude entities compiled from one or more data sources, i.e. origins, specify:
type:Organization origins!="wikidata.org" origins!="en.wikipedia.org"
The above example excludes all Organizations whose origins do not include Wikipedia or Wikidata.
Greater / Less Than (or Equal To)
We can apply the >
(greater than), <
(less than), >=
(greater than or equal to) and <=
(less than or equal to) operators to specify that the value of a field should fall within a particular range.
This query will match all Articles published to “*.nytimes.*” since Mar 1, 2022:
type:Article date>='2022-03-01' pageUrl:"nytimes" sortBy:date
This query will match companies who have between 500 and 1000 employees:
type:Organization nbEmployees>=500 nbEmployees<=1000
Strict Operator (Equals)
The strict operator modifies a text search on a field, so that the field value must be exactly equal to the search string in order for a match to occur.
We have seen in all of the examples above how the colon operator (:
) is used to match a field with a value, similar to the equals operator in most programming languages. It is important to note that the colon does not perform an exact match. It will account for a single missing word in the result. To perform an exact match you must apply the strict operator.
For example: To match only Facebook, and not Facebook affiliates:
Updated 5 months ago