orientdb-gremlin icon indicating copy to clipboard operation
orientdb-gremlin copied to clipboard

Multi-Properties

Open flaviocordova opened this issue 7 years ago • 5 comments

Tinkerpop Documentation says a property may have more than one value (http://tinkerpop.apache.org/docs/current/reference/#vertex-properties).

Just as an example: this works on gremlin console:

graph = TinkerGraph.open(); g = graph.traversal(); v = graph.addVertex("User"); v.property("name", "New with list prop"); v.property(list, "prop1", "value 1"); v.property(list, "prop1", "value 2"); g.V().has("prop1", "value 1").has("prop1", "value 2").values("name")

When using orientdb-gremlin it will override "value1" and keep only the last value, invalidating the query.

I tried using v.property("prop1", Arrays.asList("value1", "value2")) and indeed it saved the values in the database, but then you can't query using only one of the values.

flaviocordova avatar Feb 25 '17 15:02 flaviocordova

Well, not all tinkerpop features are compatible with orient.

This is one of them.

Take vanilla OrientDB. Set a property. Set it again. It just overrides. Like a java map

velo avatar Feb 25 '17 18:02 velo

Not exactly... OrientDB supports what it call "embedded list" and embedded set that match with both Cardinality.set and Cardinality.list. Couldn't the gremlin layer just select the suitable type according the the propertiy's cardinality ? It seems to make sense....

Once this working property, the has step (has(prop, value)) could just check see the field type to adapt the query. The query bellow works fine in OrientDB Studio and it looks pretty much to the same.

select * from V_User where prop3 contains 'value1' and prop3 contains 'value 2'

I understand there must be much more underneath then just data types and sql, but it doesn't seems to be impossible and it look much more elegant than Neo4j's driver approach (to create hidden vertices to store the values).

flaviocordova avatar Feb 25 '17 23:02 flaviocordova

I haven't tested but according to the documentation, embedded list/set fields can be even indexed:

orientdb> CREATE PROPERTY Book.author STRING orientdb> CREATE PROPERTY Book.title STRING orientdb> CREATE PROPERTY Book.publicationYears EMBEDDEDLIST INTEGER orientdb> CREATE INDEX books ON Book (author, title, publicationYears) UNIQUE

flaviocordova avatar Feb 25 '17 23:02 flaviocordova

The question would then become: how to replace "prop1"

I'm not sure at this point how to differ append from override

On Sun, 26 Feb 2017, 12:54 flaviocordova [email protected] wrote:

I haven't tested but according to the documentation, embedded list/set fields can be even indexed:

orientdb> CREATE PROPERTY Book.author STRING orientdb> CREATE PROPERTY Book.title STRING orientdb> CREATE PROPERTY Book.publicationYears EMBEDDEDLIST INTEGER orientdb> CREATE INDEX books ON Book (author, title, publicationYears) UNIQUE

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/orientechnologies/orientdb-gremlin/issues/120#issuecomment-282521522, or mute the thread https://github.com/notifications/unsubscribe-auth/AAIVjvyXFSy7Guq2CZTa77zXSPgOuXKFks5rgL8lgaJpZM4MMCl_ .

velo avatar Feb 26 '17 05:02 velo

Well, IMHO the proper way to set the property is using the Cardinality parameter to make explicit which behavior is expected. When cardinality is not specified, I don't see any problem if the provider choose whatever approach it want.

In other words, it's ok to replace as long as there's a way to aggregate.

flaviocordova avatar Feb 26 '17 05:02 flaviocordova