Analyzer
Operations scoped to a single ArangoSearch analyzer on the server.
Instances are obtained through Database::analyzer() or
Database::createAnalyzer(). The analyzer name is fixed at
construction time and is interpolated into the
/_api/analyzer/{name} routes by the helpers below.
The class covers the analyzer lifecycle (create / get /
drop / exists) — there is no update route on the
analyzer API, so changes always go through a drop + create cycle.
Example:
$analyzer = $db->createAnalyzer
(
'text_en' ,
new TextAnalyzer( locale : 'en' ) ,
[ AnalyzerFeature::FREQUENCY , AnalyzerFeature::POSITION ] ,
) ;
if ( $analyzer->exists() )
{
$analyzer->drop() ;
}
Tags
Table of Contents
Constants
- FORCE_PARAM : string = 'force'
- Query parameter that forces the drop of an analyzer currently in use by an arangosearch view or an inverted index (`DELETE /_api/analyzer/{name}?force=true`).
Properties
Methods
- __construct() : mixed
- create() : array<string, mixed>
- Creates this analyzer on the server with the given options.
- drop() : void
- Drops this analyzer from the server.
- exists() : bool
- Returns true when this analyzer currently exists on the server.
- get() : array<string, mixed>
- Returns the raw server-side description of this analyzer (`GET /_api/analyzer/{name}`).
- getName() : string
- Returns the analyzer name this instance is bound to.
- path() : string
- Builds the `/_api/analyzer/{name}` path with the analyzer name URL-encoded.
Constants
FORCE_PARAM
Query parameter that forces the drop of an analyzer currently in use by an arangosearch view or an inverted index (`DELETE /_api/analyzer/{name}?force=true`).
public
string
FORCE_PARAM
= 'force'
Properties
$database
public
Database
$database
$name
public
string
$name
Methods
__construct()
public
__construct(Database $database, string $name) : mixed
Parameters
- $database : Database
-
Parent database (provides the shared HTTP transport).
- $name : string
-
Name of the target analyzer on the server.
create()
Creates this analyzer on the server with the given options.
public
create(AnalyzerOptions $options[, array<int, string> $features = [] ]) : array<string, mixed>
Wraps POST /_api/analyzer. The analyzer name is taken from
$name. Features (frequency / norm / position /
offset, listed as entries of
AnalyzerFeature)
are optional — when omitted, the analyzer is created without
any feature, which is enough for plain STARTS_WITH() /
exact-match queries but not for BM25() / TFIDF() /
PHRASE().
Parameters
- $options : AnalyzerOptions
-
Type-specific options.
- $features : array<int, string> = []
-
Optional list of analyzer features (entries of AnalyzerFeature).
Tags
Return values
array<string, mixed> —Raw analyzer description as returned by the server.
drop()
Drops this analyzer from the server.
public
drop([bool $force = false ]) : void
Wraps DELETE /_api/analyzer/{name}. When $force is true,
the server allows the drop even when the analyzer is currently
referenced by an arangosearch view or an inverted index (the
reference is left dangling — use with care).
Parameters
- $force : bool = false
-
Whether to force the drop even when the analyzer is in use.
Tags
exists()
Returns true when this analyzer currently exists on the server.
public
exists() : bool
Treats a 404 as a clean "missing" and rethrows everything else.
Tags
Return values
boolget()
Returns the raw server-side description of this analyzer (`GET /_api/analyzer/{name}`).
public
get() : array<string, mixed>
Carries name / type / features / properties. The
properties shape depends on the analyzer type — see
TextAnalyzer, NormAnalyzer, StemAnalyzer
and IdentityAnalyzer.
Tags
Return values
array<string, mixed>getName()
Returns the analyzer name this instance is bound to.
public
getName() : string
Return values
stringpath()
Builds the `/_api/analyzer/{name}` path with the analyzer name URL-encoded.
private
path() : string