Search code examples
javaarcadedb

Ceation of Index with OSQL


When I try to create an index on a class with a name, it gives error.

The SQL is as under and the error.

On the other hand if I create without the name, it creates the index. I have referred: CREATE INDEX, it talks about manual index names, which is not clear to me; I take it that it is the name of the index (traditionally).

Could anyone point me to the right direction of why the below statement is not working and what is the right way of creating an index with name.

CREATE INDEX idxName IF NOT EXISTS ON GeneralizedInformationRoot (name) UNIQUE;

The error

Cannot execute command Encountered "(" "(" at line 1, column 66. Was expecting one of: <EOF> <NULL_STRATEGY> ... <METADATA> ... ";" ... "," ... 

Solution

  • Try removing the name, like this:

    CREATE INDEX IF NOT EXISTS ON GeneralizedInformationRoot (name) UNIQUE;
    

    In the link you provided states:

    Only for manual indexes, defines the logical name for the index. For automatic indexes, the index name is assigned automatically by ArcadeDB at creation as [[,]*]. For example, the index created on type Friend, properties "firstName" and "lastName", it will be named "Friend[firstName,lastName]

    In your case the index is automatic, so the name is automatically assigned.