how could I create index with META by using JavaAPI?

62 views
Skip to first unread message

Hung Tran

unread,
Jan 3, 2016, 2:02:47 AM1/3/16
to OrientDB
Hi,

I am trying to create an index with META by using JavaAPI, however I get an runtime error "com.orientechnologies.orient.core.exception.OSerializationException" and error message is "Error on unmarshalling JSON content: content must be between { }"

oProp.createIndex(OClass.INDEX_TYPE.NOTUNIQUE_HASH_INDEX + " METADATA {ignoreNullValues: false}")

Any help will be really appreciated!

My Best,
Hung Tran

alessand...@gmail.com

unread,
Jan 4, 2016, 5:22:11 AM1/4/16
to OrientDB
Try with this code

OSchema schema = db.getMetadata().getSchema();

OClass oClass = schema.createClass("Place");
oClass
.createProperty("name", OType.STRING);
 
OPropertyIndexDefinition op=new OPropertyIndexDefinition("Place", "name", OType.STRING);
op
.setNullValuesIgnored(false);
OIndexManagerProxy im = db.getMetadata().getIndexManager();
im
.createIndex("Place.name", "NOTUNIQUE_HASH_INDEX", op, null, null, null );

Kind regards,
Alessandro

Hung Tran

unread,
Jan 4, 2016, 2:03:53 PM1/4/16
to orient-...@googlegroups.com
Hi Alessandro,

Thank you, it's working. Thank you to introduce me about OPropertyIndexDefinition class, now I could access an instance of IndexDefinition to update that value.

In my case, it would be easier,

oProp.createIndex(OClass.INDEX_TYPE.NOTUNIQUE_HASH_INDEX).getDefinition().setNullValuesIgnored(false)

My Best,
Hung Tran

Hung Tran

unread,
Jan 4, 2016, 2:59:14 PM1/4/16
to orient-...@googlegroups.com
Hi,

Just a confirmation that, my code below does not working

oProp.createIndex(OClass.INDEX_TYPE.NOTUNIQUE_HASH_INDEX).getDefinition().setNullValuesIgnored(false)

A runtime error is "Error on executing command: sql.create index ExternalAccount.LastModifiedBy NOTUNIQUE_HASH_INDEX LINK" (I have copied the SQL and run with Studio, it's working => it seems that the JavaAPI does not work in this case)

It seems to be not working with a LINK?

Any help will be really appreciated!
Hung Tran

Hung Tran

unread,
Jan 11, 2016, 4:58:49 AM1/11/16
to OrientDB
Hi,

I would like to confirm, that code is not working for a LINK in OrientDB 1.7.8, but it's working well in the latest version 2.1.8

Thanks,
Hung Tran
Reply all
Reply to author
Forward
0 new messages