Morgan Smith
Morgan Smith

Reputation: 301

How do I see if a value exists in any property for gremlin?

I have a gremlin 3.4.9 set up, with a few different types of vertexes. (people, jobs, homes for example). I want to be able to traverse all of these samples and see if any of the properties contain a value. for example:

I have a:

people vertex with the properties: name, age, location, bio

job vertex with the properties: title, pay, location, description

home vertex with the properties: cost, location, description

and I want to see if any of these properties of these vertices contain the value "family". What would that query look like?

Upvotes: 1

Views: 2250

Answers (2)

bechbd
bechbd

Reputation: 6341

You can accomplish this using a combination of the properties() step and the hasValue() step like below. However, I would not expect this to be very performant on most/all databases as it will be unable to use any indexes or optimizations.

g.V().where(properties().hasValue("family"))

Properties Step

Has Step

Upvotes: 2

blurfus
blurfus

Reputation: 14041

You can search the properties values like this:

g.V().properties().hasValue("family");

This seems to work across different Vertices (which I believe is what you are looking for)

Upvotes: 1

Related Questions