What is a Document Query?



documentQuery examples

Query collection - no filtering

// load all entities from 'Employees' collection
$employees = $session
    ->advanced()
    ->documentQuery(Employee::class)
    ->toList();
from "Employees"

Query collection - with filtering

// load all entities from 'Employees' collection
// where firstName equals 'Robert'
$employees = $session
    ->advanced()
    ->documentQuery(Employee::class)
    ->whereEquals("FirstName", "Robert")
    ->toList();
from "Employees" where FirstName == "Robert"

Query an index

  • Using a Path string

    // load all entities from 'Employees' collection
    // where firstName equals 'Robert'
    // using 'My/Custom/Index'
    $employees = $session
        ->advanced()
        ->documentQuery(Employee::class, "My/Custom/Index", null, false)
        ->whereEquals("FirstName", "Robert")
        ->toList();
    )
  • Using an index Class

    // load all entities from 'Employees' collection
    // where firstName equals 'Robert'
    // using 'MyCustomIndex::class'
    $employees = $session
        ->advanced()
        ->documentQuery(Employee::class, MyCustomIndex::class)
        ->whereEquals("FirstName", "Robert")
        ->toList();
    )

Please refer to Querying an index for examples of querying an index using a documentQuery.

Custom Methods

Several methods share the same functionality as their query counterparts.
Refer to the corresponding documentation articles, marked with links starting with "[Query]" in the list below.

Available custom methods:

Syntax

The definition for documentQuery is listed in the Syntax section of the Query Overview.