Near Operator

The near operator searches for entities that are located within a particular distance (default 15km) of another entity - typically a Place. It is always coupled with a single-field subquery that returns one or more Place entities.

Using DQL query as a parameter to near

This query returns all Organization entities that are located within 15km of San Francisco:
type:Organization near(type:Place name:"San Francisco")

This query returns all Mexican restaurants near Diffbot:
type:Organization descriptors:"mexican restaurant" near(type:Organization name:"Diffbot")

near can only operate on a single entity, so if the subquery returns more than one result, near will only operate on the first entity returned. By default, all results are sorted by importance (as defined by the importance field in the KG results for that entity).

For example: this query returns all Organizations with “Bank” in their name, that are within 15km of the most important AdministrativeArea named "Springfield":
type:Organization name:"Bank" near(name:"Springfield")

There are many places in the world named "Springfield" (for example, "Springfield, Illinois" in the United States and "Springfield, Birmingham" in England, but near will compare the importance fields of all of them and operate only on the most important entity.

Note that if the type clause is not specified, it defaults to Place. For example, type:Organization near(name:"Springfield") is the same as type:Organization near(type:Place name:"Springfield").

Specifying radius of search

near accepts an optional distance modifier, to specify the maximum radius from the Place that a returned entity should be located within. Units for distance can be given in miles (mi) or kilometers (km).

For example: This query returns all companies whose business is associated in some way with banking, that are also located within 10 miles of San Francisco, CA (the “most important” city named San Francisco):
type:Organization categories.name:"banking" near(name:"San Francisco", 10mi)

Specifying location field

By default, the near operator uses the location field in the top result to resolve the latitude and longitude of the place to search around. With a clause like near(name:"San Francisco"), DQL first queries for

📘

Searching for restaurants near a company

The requirement for the DQL query specified in the near operator is that the result should contain a location field. Organization entities have a location field and can be used inside near queries as well. For example, to find all Mexican restaurants near Diffbot, you can specify:
type:Organization descriptors:"mexican restaurant" near(type:Organization name:"Diffbot")

Using latitude/longitude as parameters to near


Did this page help you?