Multiple Index on the same property

48 views
Skip to first unread message

K Major

unread,
Apr 13, 2016, 12:08:04 PM4/13/16
to OrientDB

Hello,

Apparently it's not possible to add two different types of index on the same property.

For instance, I would like to add a Hash index but also a BTree index on the same property. 

So, according to the query, the best index would be used. (Use Btree index if query is a range query, or use Hash index if a just want to get a value)

Is that possible ?

alessand...@gmail.com

unread,
Apr 14, 2016, 12:03:00 PM4/14/16
to OrientDB
Hi,
I did the following test.
I had two indices on the property name on the class V


I had these records.


the two indices were used




Hope it helps.

Best regards,
Alessandro







K Major

unread,
Apr 15, 2016, 10:50:02 AM4/15/16
to OrientDB
Hum maybe a bug in the Java API then ?

Here is my piece of code 


graphDb.createVertexType("Person");

OrientVertexType type= graphDb.getVertexType("Person");
type.createProperty("name", OType.INTEGER).createIndex("UNIQUE_HASH_INDEX");
type.createProperty("age", OType.INTEGER).createIndex("NOTUNIQUE"); 
type.getProperty("age").createIndex("NOTUNIQUE_HASH_INDEX"); 


I'm trying to create an SBTree index and Hash index on the age property.

The last line yields the error : 

Index with name person.age already exists.
Message has been deleted

alessand...@gmail.com

unread,
Apr 15, 2016, 11:54:01 AM4/15/16
to OrientDB
Hi,
you can try with the following code.

OrientGraphNoTx g = new OrientGraphNoTx(path);
OClass person = g.getRawGraph().getMetadata().getSchema().getClass("Person");
person
.createProperty("name", OType.INTEGER).createIndex("UNIQUE_HASH_INDEX");
person
.createProperty("age", OType.INTEGER).createIndex("NOTUNIQUE");
person
.createIndex("age2", OClass.INDEX_TYPE.NOTUNIQUE_HASH_INDEX, "age");
g
.shutdown();



Hope it helps.

Alessandro
Reply all
Reply to author
Forward
0 new messages