Oihana PHP Arango

inRange.php

Table of Contents

Functions

inRange()  : string
Match documents where an attribute is within a range (index-accelerated).

Functions

inRange()

Match documents where an attribute is within a range (index-accelerated).

inRange(string $path, mixed $low, mixed $high, bool $includeLow, bool $includeHigh) : string

Wraps the ArangoDB AQL function IN_RANGE(path, low, high, includeLow, includeHigh). Inside a SEARCH operation it searches more efficiently than the equivalent pair of comparisons combined with AND; the same function also exists as a miscellaneous function outside of SEARCH (hence the constant living in MiscFunction).

low and high can be numbers or strings, but both must share the same data type. Note that string ranges in SEARCH follow byte order, not the Analyzer locale collation.

Example AQL usage:

IN_RANGE(doc.value, 3, 5, true, true)     // 3 <= value <= 5
IN_RANGE(doc.value, "a", "f", true, false) // "a" <= value < "f"
Parameters
$path : string

Attribute path expression to test (kept raw).

$low : mixed

Minimum value of the range (JSON-encoded: strings are quoted, numbers kept raw).

$high : mixed

Maximum value of the range (JSON-encoded, same data type as $low).

$includeLow : bool

Whether the minimum value is included (left-closed interval).

$includeHigh : bool

Whether the maximum value is included (right-closed interval).

Tags
example
use function oihana\arango\db\functions\search\inRange;

echo inRange( 'doc.value' , 3 , 5 , true , true ) ;
// 'IN_RANGE(doc.value,3,5,true,true)'

echo inRange( 'doc.value' , 'a' , 'f' , true , false ) ;
// 'IN_RANGE(doc.value,"a","f",true,false)'
see
https://docs.arangodb.com/stable/aql/functions/arangosearch/#in_range
since
1.2.0
author

Marc Alcaraz

Return values
string

The formatted AQL expression.

On this page

Search results