Dor Cohen
Dor Cohen

Reputation: 17080

OrientDB force property type to be string

I'm using OrientDB and trying to create new property after I inserted my data (millions of rows).

I'm trying to create property on V in order to create an index and I'm getting the following error:

The database contains some schema-less data in the property 'V.ACCOUNT_NO' that is not compatible with the type STRING. Fix those records and change the schema again [ONetworkProtocolHttpDb]

Now part of the fields type is INTEGER but it seems to me that it's very easy to convert the type to STRING.
how can I do it to the entire data?

Upvotes: 2

Views: 271

Answers (1)

LucaS
LucaS

Reputation: 1418

I tried your case by creating this simple structure in schema-less mode:

enter image description here

These records are a mix of INTEGER and STRING types:

enter image description here

Now you can convert the not string records type by using this query:

UPDATE V SET ACCOUNT_NO = ACCOUNT_NO.asString() WHERE ACCOUNT_NO.type() <> 'STRING'

Output:

enter image description here

About the exception, I got correctly the same error when I try to create a new property V.ACCOUNT_NO of type STRING in schema-full mode and this is correct because the property already exists in the database and contains mixed types of records, although in schema-less mode.

Once all the records were converted, you'll able to create the new property.

enter image description here

Hope it helps

Upvotes: 5

Related Questions