jj pan
jj pan

Reputation: 307

Gremlin to retrieve multiple properties based on its metaproperties

I need to retrieve the vertex based on the metaproperties of several properties.

p.addV('v01').
    property(list, 'p01', 'p01value01', 'modified_by', 'user01', 'modified_date', '12/12/9999')
    property(list, 'p02', 'p02value01', 'modified_by', 'user01', 'modified_date', '12/12/2021')

p.addV('v01').
    property(list, 'p01', 'p01value02', 'modified_by', 'user01', 'modified_date', '12/12/2021')
    property(list, 'p02', 'p02value02', 'modified_by', 'user01', 'modified_date', '12/12/9999')

How do select the properties where the metaproperties (modified_by == '12/12/9999')

Upvotes: 1

Views: 95

Answers (1)

Kelvin Lawrence
Kelvin Lawrence

Reputation: 14371

You can access the meta properties as shown below. The where step filters out any vertex that does not have a property that matches. Youn can modify this query any way you need to if you want to return properties rather than vertices

g.V().where(properties().properties('modified_date').hasValue('12/12/9999'))

If you want the properties you can just move the where step.

g.V().properties().where(properties('modified_date').hasValue('12/12/9999')))

Upvotes: 3

Related Questions