Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot create property-index on graph loaded via gremlin API #170

Closed
MartinBrugnara opened this issue Mar 10, 2020 · 2 comments
Closed

Cannot create property-index on graph loaded via gremlin API #170

MartinBrugnara opened this issue Mar 10, 2020 · 2 comments
Assignees

Comments

@MartinBrugnara
Copy link

Version: 3.0.27
Store: plocal

Issue

I cannot create an index on any property when the graph is loaded via the gremlin API.

Questions

  • Should I manually alter the schema to make it aware of the properties or there is way to auto discover it ?
  • In case I need to create the schema a-priory, what's the recommend way to do so?

Context & Code

Loading code:

GraphSONReader.build().create().readGraph(new FileInputStream(new File(dataset)), g);

Partial, relevant, loading log:

INFO: $ANSI{green {db=thedb}} created class 'software' as subclass of 'V'

Index creation code:

String label = "software";
String prop_name = "lang";

OrientGraph og = (OrientGraph)g;
String query = "CREATE INDEX %1$s_%2$s_index ON %1$s (%2$s) NOTUNIQUE METADATA {ignoreNullValues: true}";
String cls = og.labelToClassName(label, "V");
og.executeSql(String.format(query, cls, prop_name));
og.commit();

Stacktrace:

com.orientechnologies.orient.core.index.OIndexException: Index with name 'software_lang_index' cannot be created on class 'software' because the field 'lang' is absent in class definition
	DB name="thedb"
	at com.orientechnologies.orient.core.metadata.schema.OClassImpl.createIndex(OClassImpl.java:1155)
	at com.orientechnologies.orient.core.sql.parser.OCreateIndexStatement.getoIndex(OCreateIndexStatement.java:133)
	at com.orientechnologies.orient.core.sql.parser.OCreateIndexStatement.execute(OCreateIndexStatement.java:119)
	at com.orientechnologies.orient.core.sql.parser.OCreateIndexStatement.executeDDL(OCreateIndexStatement.java:54)
	at com.orientechnologies.orient.core.sql.executor.ODDLExecutionPlan.executeInternal(ODDLExecutionPlan.java:55)
	at com.orientechnologies.orient.core.sql.parser.ODDLStatement.execute(ODDLStatement.java:42)
	at com.orientechnologies.orient.core.sql.parser.OStatement.execute(OStatement.java:79)
	at com.orientechnologies.orient.core.db.document.ODatabaseDocumentEmbedded.command(ODatabaseDocumentEmbedded.java:567)
	at org.apache.tinkerpop.gremlin.orientdb.OrientGraph.executeSql(OrientGraph.java:230)
	at com.graphbenchmark.shell.orientdb.IndexMgm.node(IndexMgm.java:26)
	at com.graphbenchmark.queries.mgm.CreateIndexes.lambda$query$0(CreateIndexes.java:37)
        ...
@luigidellaquila
Copy link
Member

Hi @MartinBrugnara

There is no way to auto-discover properties, so I'm afraid you will have to create them manually.
My suggestion is to use plain SQL to do it

Thanks

Luigi

@MartinBrugnara
Copy link
Author

Thanks @luigidellaquila for the quick and clear response.

I proceed to close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants