Simple & Nested Paths

a.k.a. AND queries

Simple Paths

A query can contain multiple search clauses (i.e. multiple fields), all of which must match in order for an entity to be returned. In other words, with DQL, AND queries are implied for the entirety of a single query.

To perform an AND query, we separate our field-value combinations with a space.

For example: This query returns all Organizations located in San Francisco with more than 5000 employees across all of their locations:

type:Organization locations.city.name:"San Francisco" nbEmployees>5000

You can find all types and fields that you can use in your filters in the Ontology.


Nested Paths

Nested queries search against nested fields. By wrapping multiple subfields of a field into a single query, it can return results for which all of those subfields match an entity at the same time.

Let's take a look at this query which is trying to find organizations that are currently located in San Francisco:

type:Organization locations.isCurrent:true locations.city.name:"San Francisco"

Unfortunately, this query would not have the intended result. This query specifies that an Organization must have a location "San Francisco", and that there must be a location for which isCurrent is true, but it does not specify that both must be true for the same location. This query will also match organizations which were previously located in San Francisco but may have since relocated.

The correct way to approach such a problem is to nest the subfields (isCurrent and city.name) we are searching on, using curly braces. The above query rewritten as a nested query looks like this:

type:Organization locations.{isCurrent:true city.name:"San Francisco"}

It is also possible to have nested queries within nested queries. Here is an example:

type:Organization ceo.{locations.city.name:"San Francisco" educations.{degree.name:"Master’s" institution.name:"Stanford"}}

This query will match all organizations whose CEO is located in San Francisco and has a Masters Degree from Stanford.

📘

Nested queries are limited to three levels of nesting.