Oihana PHP Arango

tokens.php

Table of Contents

Functions

tokens()  : string
Split input string(s) using the specified analyzer into an array of tokens.

Functions

tokens()

Split input string(s) using the specified analyzer into an array of tokens.

tokens(string $init, string $analyzer) : string

This helper wraps the ArangoDB AQL function TOKENS(input, analyzer) which splits the input text using the specified analyzer and returns an array of tokens. This is useful for text analysis and search operations.

Example AQL usage:

TOKENS("hello world", "text_en")          // returns ["hello", "world"]
TOKENS("Hello, World!", "text_en")        // returns ["hello", "world"]
TOKENS(doc.content, "text_en")            // returns tokens from content
Parameters
$init : string

Text expression to tokenize (accepts recursive arrays of strings).

$analyzer : string

Name of the analyzer to use for tokenization.

Tags
example
use function oihana\arango\db\functions\strings\tokens;

$expr = tokens('doc.content', '"text_en"');
// Produces: 'TOKENS(doc.content, "text_en")'
see
https://docs.arangodb.com/3.12/aql/functions/string/#tokens
split()

For simple string splitting.

since
1.0.0
author

Marc Alcaraz

Return values
string

The formatted AQL expression.

On this page

Search results