Warning when creating a non-unique index

When creating a non-unique hash index on a Vertex I’m getting the following warning: “WARNING: Invalid type index: -1” although the index is created properly.
The Java code is:
c1 = session.createClass(“Audit_Trail”);

c1 .createProperty(“timestamp”, OType.DATETIME);

c1.createIndex(“Audit_Trail_IX1”, OClass.INDEX_TYPE.NOTUNIQUE_HASH_INDEX, “timestamp”);

I’m trying with just a basic remote connect on demodb but it’s working correctly without warnings, can you run a check database and post results?
Here’s my current snippet:

OrientDB orientDb = new OrientDB("remote:localhost", OrientDBConfig.defaultConfig());
ODatabaseSession session = orientDb.open("demodb", "root", "root");
OClass c = session.createClass("Audit_Trail");
c.createProperty("timestamp", OType.DATETIME);
c.createIndex("Audit_Trail_IX1", OClass.INDEX_TYPE.NOTUNIQUE_HASH_INDEX, "timestamp");

Hi I finally narrowed it down. Just try and set the default attribute for the property - e.g.
OrientDB orientDb = new OrientDB(“remote:localhost”, OrientDBConfig.defaultConfig());
ODatabaseSession session = orientDb.open(“demodb”, “root”, “root”);
OClass c = session.createClass(“Audit_Trail”);
OProperty p;
p = c.createProperty(“timestamp”, OType.DATETIME);
c.createIndex(“Audit_Trail_IX1”, OClass.INDEX_TYPE.NOTUNIQUE_HASH_INDEX, “timestamp”);

And see what happens.

Hi, I’ve pasted your edit but I still can’t reproduce that warning:

Are you executing it on a fresh install with demodb?
Which version of OrientDB are you using?

Completely fresh - I’ve just downloaded it when you posted your code. The version of OrientDB is 3.0.12.
I’m also repeating that it actually doesn’t cause any harm. The class is created correctly and the index is also there and working - it’s just annoying to get a meaningless warning.
I have initially tested with your code as is and there was no warning. Then I have added the 3 attributes that I have for this property (mandatory, not null and default value) and the warning appeared. I have masked the default value attribute and tried again and the warning was gone. Then I have removed the other two attributes leaving just the default value and the warning re-appeared.

Some additional info. I’ve debugged through the code and found that the problem is not with the createIndex but with the OProperty.setDefaultValue() method. This method call is the one that creates the warning.
Hope it helps.

As I said it before the warning is not because of an index by because of the setDefaultValue method.
Here is a sample code that produces the “WARNING: Invalid type index: -1”:
if (session.getClass(“Relationship_Rules”) == null)
seqLib = session.getMetadata().getSequenceLibrary();
if (seqLib.getSequence(“rel_rule_id”) == null)
seqLib.createSequence(“rel_rule_id”, OSequence.SEQUENCE_TYPE.ORDERED, new OSequence.CreateParams().setStart(0L).setIncrement(1));
c = session.createClass(“Relationship_Rules”);
p = c.createProperty(“id”, OType.LONG);
c.createProperty(“description”, OType.STRING);
p = c.createProperty(“owner”, OType.STRING);
p = c.createProperty(“from_class”, OType.STRING);
p = c.createProperty(“to_class”, OType.STRING);
p = c.createProperty(“filter”, OType.EMBEDDED);
p = c.createProperty(“rules”, OType.EMBEDDEDMAP);
p = c.createProperty(“filter_statement”, OType.EMBEDDED);
c.createIndex(“Relationship_Rules_PK”, OClass.INDEX_TYPE.UNIQUE_HASH_INDEX, “id”);
c.createIndex(“Relationship_Rules_IX”, OClass.INDEX_TYPE.NOTUNIQUE_HASH_INDEX, “from_class”, “to_class”);

The orientdb version is 3.0.14

Latest debugging: OProperty. setDefaultValue(String defaultValue) creates the warning “WARNING: Invalid type index: -1” only if the defaultValue contains a function - as in sysdate() or sequence(’…’).next()