0

I have a sample data that i modeled in my cosmos DB gremlin API. The sample csv is as follows

         Name,               Job Titles,             Department
"ADRIANO,  RACQUEL ANNE",    PARAMEDIC,              PARAMEDIC
"AFFANEH,  MAHIR A",         POLICE OFFICER,         POLICE
"AFOENYI,  PHYLLIS",         TITLE V,                PROGRAM TRAINEE I
"AGAR,  BULENT B",           DEPUTY COMMISSIONER,    WATER MGMNT

Each of these have additional metadata so i have modeled vertex typers Employee, Job and Department.

I am trying to run a query that gives me at most 20 of the police officers that have the David in their name. This is the query I am running.

g.V().has('label', 'Employee').has('name', TextP.containing('DAVID')).as('a').outE('works_as').otherV().has('name', 'POLICE OFFICER').select('a').limit(20)

This is consuming a lot of RUs even though i am only returning 20 of them. I have modified the query slightly to flip the query order to below, but this is performing worse RU wise.

g.V().has('name', 'POLICE OFFICER').inE().outV().has('name', TextP.containing('DAVID')).limit(20)

Is there anyway I can improve this query to cost me lower RUs?

Michael Scott
  • 540
  • 2
  • 8
  • I've not used the Gremlin API, but this kind of query would be very cheap through the SQL API. If there's not a specific reason to use a graph, it might be worth trying a more traditional modeling and the SQL API. – Noah Stahl Jul 24 '20 at 20:15
  • 1
    This is only a sample for test purposes. We do have a lot of hierarchical data and custom relationships between objects that is requiring us to use a graph and searching/filtering queries like these are required on those. – Michael Scott Jul 24 '20 at 20:45

0 Answers0