Search using tuple and user-defined type (UDT) values
Tuple search
Tuple search is used to discover values stored within tuples. Search indexes make such searches possible. First, a search index must be created.
schema.vertexLabel('person').searchIndex().ifNotExists().by('country').create()
This query is looking for all persons that lived in some country until the date 1960-01-01
, with country.field2
storing the value of end_date
for a tuple that stores country, start_date, end_date
.
g.V().has('person', 'country.field2', '1960-01-01' as LocalDate)
results in:
==>v[dseg:/person/e7cd5752-bc0d-4157-a80f-7523add8dbcd]
who happens to be Julia CHILD
.
So, to search for a matching value in a tuple, the tuple name and the field number must be supplied.
The fields begin with field0
.
UDT search
UDT search is used to discover values stored within UDTs or nested UDTs. Search indexes make such searches possible. First, a search index must be created.
schema.vertexLabel('location').searchIndex().ifNotExists().by('loc_details').create()
This query is looking for all persons that lived in some country until the date 1960-01-01
, with country.field2
storing the value of end_date
for a tuple that stores country, start_date, end_date
.
g.V().has('location', 'loc_details.loc_address.address1' , '213 F St')
results in:
==>v[dseg:/location/g13]
which happens to be Zippy Mart
.
So, to search for a matching value in a UDT, the tuple name and each of the nested field number must be supplied.
In this case, the property loc_details
is a UDT with its own property loc_address
which is also a UDT that has a property address1
that is a street address.