-
Notifications
You must be signed in to change notification settings - Fork 21
Full Text Index
A full text index can be created using the OrientDB SQL syntax as written here. You must specify the index engine to use to enable the lucene full text capabilities.
Syntax:
CREATE INDEX <name> ON <class-name> (prop-names) FULLTEXT ENGINE LUCENE
Example
create index City.name on City (name) FULLTEXT ENGINE LUCENE
An index can also be created on n-properties:
Example:
create index City.name_description on City (name,description) FULLTEXT ENGINE LUCENE
This will create a basic Lucene index on the properties specified. If the analyzer is not specified, the default will be the StandardAnalyzer. To use a different analyzer use the field analyzer in the metadata JSON object in the CREATE INDEX syntax.
Example:
create index City.name on City (name) FULLTEXT ENGINE LUCENE METADATA {"analyzer":"org.apache.lucene.analysis.en.EnglishAnalyzer"}
The Index can also be created with the Java API. Example:
OSchema schema = databaseDocumentTx.getMetadata().getSchema();
OClass oClass = schema.createClass("Foo");
oClass.createProperty("name", OType.STRING);
oClass.createIndex("City.name", "FULLTEXT", null, null, "LUCENE", new String[] { "name"});
The full text index can be queried using the custom operator LUCENE
using the Query Parser Syntax of Lucene. Example:
select * from V where name LUCENE "test*"
will look for test, tests or tester etc..
To query multiple fields use this special syntax:
select * from Class where [prop1,prop2] LUCENE "query"
If the query is a plain string the engine will parse the query using MultiFieldQueryParser on each indexed field.
To execute a more complex query on each field surround your query with ()
parentheses, to use specific fields.
Example:
select * from Class where [prop1,prop2] LUCENE "(prop1:foo AND props2:bar)"
With this syntax the engine parses the query using the QueryParser.
Starting from 2.1, the plugin supports index creation without the need of a class
To create a manual index use this syntax
CREATE INDEX <name> FULLTEXT ENGINE LUCENE [<key-type>] [METADATA {<metadata>}]
Example
create index Manual FULLTEXT ENGINE LUCENE STRING,STRING
You can then insert values in the index as follows:
insert into index:manual (key,rid) values(['Enrico','Rome'],#5:0)
and query the index:
select from index:manual where key LUCENE 'Enrico'
Home - OrientDB Engine - Professional Support - Courses - Team
Copyright (C) Orient Technologies LTD - All rights reserved.
<script> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga');ga('create', 'UA-28543690-2', 'orientechnologies.com'); ga('send', 'pageview'); </script>