Analyzer Management

The JavaScript API can be accessed via the @arangodb/analyzers module fromboth server-side and client-side code (arangosh, Foxx):

  1. var analyzers = require("@arangodb/analyzers");

See Analyzers for general information anddetails about the attributes.

Analyzer Module Methods

Create an Analyzer

  1. var analyzer = analyzers.save(<name>, <type>[, <properties>[, <features>]])

Create a new Analyzer with custom configuration in the current database.

  • name (string): name for identifying the Analyzer later
  • type (string): the kind of Analyzer to create
  • properties (object, optional): settings specific to the chosen type.Most types require at least one property, so this may not be optional
  • features (array, optional): array of strings with names of the featuresto enable
  • returns analyzer (object): Analyzer object, also if an Analyzer with thesame settings exists already. An error is raised if the settings mismatchor if they are invalid
  1. arangosh> var analyzers = require("@arangodb/analyzers");
  2. arangosh> analyzers.save("csv", "delimiter", { "delimiter": "," }, []);

Show execution results

Hide execution results

  1. {
  2. "name" : "_system::csv",
  3. "type" : "delimiter",
  4. "properties" : {
  5. "delimiter" : ","
  6. },
  7. "features" : [ ]
  8. }

Get an Analyzer

  1. var analyzer = analyzers.analyzer(<name>)

Get an Analyzer by the name, stored in the current database. The name can beprefixed with _system:: to access Analyzers stored in the _system database.

  • name (string): name of the Analyzer to find
  • returns analyzer (object|null): Analyzer object if found, else null
  1. arangosh> var analyzers = require("@arangodb/analyzers");
  2. arangosh> analyzers.analyzer("text_en");

Show execution results

Hide execution results

  1. [ArangoAnalyzer "text_en" (type text)]

List all Analyzers

  1. var analyzerArray = analyzers.toArray()

List all Analyzers available in the current database.

  • returns analyzerArray (array): array of Analyzer objects
  1. arangosh> var analyzers = require("@arangodb/analyzers");
  2. arangosh> analyzers.toArray();

Show execution results

Hide execution results

  1. [
  2. [ArangoAnalyzer "text_sv" (type text)],
  3. [ArangoAnalyzer "text_en" (type text)],
  4. [ArangoAnalyzer "identity" (type identity)],
  5. [ArangoAnalyzer "text_es" (type text)],
  6. [ArangoAnalyzer "text_de" (type text)],
  7. [ArangoAnalyzer "text_fr" (type text)],
  8. [ArangoAnalyzer "text_no" (type text)],
  9. [ArangoAnalyzer "text_it" (type text)],
  10. [ArangoAnalyzer "text_fi" (type text)],
  11. [ArangoAnalyzer "text_nl" (type text)],
  12. [ArangoAnalyzer "text_zh" (type text)],
  13. [ArangoAnalyzer "text_pt" (type text)],
  14. [ArangoAnalyzer "text_ru" (type text)]
  15. ]

Remove an Analyzer

  1. analyzers.remove(<name> [, <force>])

Delete an Analyzer from the current database.

  • name (string): name of the Analyzer to remove
  • force (bool, optional): remove Analyzer even if in use by a View.Default: false
  • returns nothing: no return value on success, otherwise an error is raised
  1. arangosh> var analyzers = require("@arangodb/analyzers");
  2. arangosh> analyzers.remove("csv");

Show execution results

Hide execution results

  1.  

Analyzer Object Methods

Individual Analyzer objects expose getter accessors for the aforementioneddefinition attributes (see Create an Analyzer).

Get Analyzer Name

  1. var name = analyzer.name()
  • returns name (string): name of the Analyzer
  1. arangosh> var analyzers = require("@arangodb/analyzers");
  2. arangosh> analyzers.analyzer("text_en").name();

Show execution results

Hide execution results

  1. text_en

Get Analyzer Type

  1. var type = analyzer.type()
  • returns type (string): type of the Analyzer
  1. arangosh> var analyzers = require("@arangodb/analyzers");
  2. arangosh> analyzers.analyzer("text_en").type();

Show execution results

Hide execution results

  1. text

Get Analyzer Properties

  1. var properties = analyzer.properties()
  • returns properties (object): type dependent properties of the Analyzer
  1. arangosh> var analyzers = require("@arangodb/analyzers");
  2. arangosh> analyzers.analyzer("text_en").properties();

Show execution results

Hide execution results

  1. {
  2. "locale" : "en.utf-8",
  3. "case" : "lower",
  4. "stopwords" : [ ],
  5. "accent" : false,
  6. "stemming" : true
  7. }

Get Analyzer Features

  1. var features = analyzer.features()
  • returns features (array): array of strings with the features of the Analyzer
  1. arangosh> var analyzers = require("@arangodb/analyzers");
  2. arangosh> analyzers.analyzer("text_en").features();

Show execution results

Hide execution results

  1. [
  2. "position",
  3. "norm",
  4. "frequency"
  5. ]