aqlSearch.php
Table of Contents
Functions
- aqlSearch() : string
- Builds an AQL `SEARCH` clause for a query, with optional Analyzer wrapping and an optional `OPTIONS` object.
Functions
aqlSearch()
Builds an AQL `SEARCH` clause for a query, with optional Analyzer wrapping and an optional `OPTIONS` object.
aqlSearch([array<string|int, mixed> $init = [] ]) : string
The SEARCH operation guarantees the use of View indexes for an efficient execution plan. Using FILTER on Views does not utilize indexes and filtering is done as a post-processing step.
$init keys:
AQL::SEARCH— the search expression. Without it everything else is ignored and an empty string is returned.AQL::ANALYZER(optional) — an Analyzer name; the expression is wrapped inANALYZER(expr, "name")via analyzer(), setting the Analyzer for the expression and its nested functions.AQL::SEARCH_OPTIONS(optional) — theSEARCH … OPTIONS { … }object (collections,conditionOptimization,countApproximate,parallelism), accepted as an associative array (hydrated into SearchOptions, unknown keys dropped, null properties omitted), aSearchOptionsinstance, anyJsonSerializable/plain object, or a pre-encoded JSON string — the same tolerance as aqlOptions().
Not to be confused with AQL::OPTIONS, the FOR-level options
(indexHint, useCache, … — see ForOptions):
a FOR over a collection takes AQL::OPTIONS, a SEARCH against a View
takes AQL::SEARCH_OPTIONS. aqlFor() forwards its whole $init
here, so all three keys work through it directly.
Example:
use oihana\arango\db\enums\AQL;
use oihana\arango\db\enums\ConditionOptimization;
use function oihana\arango\db\operations\aqlSearch;
echo aqlSearch([ AQL::SEARCH => 'PHRASE(doc.text, "search phrase", "text_en")' ]) . PHP_EOL;
// SEARCH PHRASE(doc.text, "search phrase", "text_en")
echo aqlSearch
([
AQL::SEARCH => 'PHRASE(doc.text, "search phrase")' ,
AQL::ANALYZER => 'text_en' ,
AQL::SEARCH_OPTIONS => [ 'conditionOptimization' => ConditionOptimization::NONE ] ,
]) . PHP_EOL;
// SEARCH ANALYZER(PHRASE(doc.text, "search phrase"),"text_en") OPTIONS {"conditionOptimization":"none"}
echo aqlSearch(); // ''
Parameters
- $init : array<string|int, mixed> = []
-
Array containing the key
AQL::SEARCHwith the expression to search, and optionallyAQL::ANALYZERandAQL::SEARCH_OPTIONS.
Tags
Return values
string —The compiled AQL SEARCH clause, or an empty string if no search expression is provided.