OrientJS Index API

Once you have initialized a database instance, you can create and fetch indices from OrientDB, using the OrientJS Index API. This allows you to work with and take advantage of indexing features in OrientDB directly from within your application.

By convention, the variable on which you initialize the Database API is called db. This designation is arbitrary and used only for convenience.

Working with Indices

Methods tied to the Index API are accessible through the Database API: db.index.<method>. In OrientDB, indices are set as properties on the class they index.

Creating Indexes

Using the Index API, you create an index property on a given class through the db.index.create() method. For instance,

In the baseball statistics database, you may find yourself often searching for players by name. The above example creates a Full Text index on the name property of Player using the SB-Tree indexing algorithm.

Getting Indexes

In the event that you would like to operate on an index object directly from within your application, you can fetch using the db.index.get() method. You can then use the get() method on the return object to search for values. For instance,