question

baid_manish_187433 avatar image
baid_manish_187433 asked baid_manish_187433 commented

How do we perform edge search in DSE 6.8 of properties stored from IN vertex to edge?

for quick traversal, we are planning to store (denormalized) some time-related properties from IN vertex into the edge.

Edge Search (new to 6.8) cannot be performed on such node as the partitioning keys (from OUT vertex) cannot be used through Tinkerpop interface, is only way to de-normalize ALL the primary from OUT vertex into edge?

UPDATE - A bit more detail:

Event <--- Account

schema.vertexLabel('Event').
    ifNotExists().
    partitionBy('tenantId', Ascii).
    clusterBy('eventCategory', Ascii, Asc).
    clusterBy('createTime', Timestamp, Desc).
    clusterBy('gid', Uuid, Asc)
schema.vertexLabel('Account').
    ifNotExists().
    partitionBy('tenantId', Ascii).
    clusterBy('entityGlobalId', Uuid, Asc)
schema.edgeLabel('WithEvent').
    ifNotExists().
    from('Account').to('Event')
    clusterBy('acknowledged', Boolean)

Question: Need to do edge search where following are provided:

edge.acknowledged + IN-Vertex with (tenantId, eventCategory, createTime>= Jan/2020)

Will DSE Graph optimize this query to just search in the Edge table? Given it contains all the fields (properties and primary key of the incident edges).

dsegraph
3 comments
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

bettina.swynnerton avatar image bettina.swynnerton ♦♦ commented ·

To understand you better: Could you give an example of the edge search you want to perform, ideally with the desired graph schema after bringing the properties from the IN vertex into the edge?

Thanks!

0 Likes 0 ·
baid_manish_187433 avatar image baid_manish_187433 bettina.swynnerton ♦♦ commented ·

[Updated original question with details]

0 Likes 0 ·
bettina.swynnerton avatar image bettina.swynnerton ♦♦ baid_manish_187433 commented ·

thanks, I understand much better what you are trying to achieve. I will do some tests and research to see how this edge can be searched.

0 Likes 0 ·

1 Answer

bettina.swynnerton avatar image
bettina.swynnerton answered baid_manish_187433 commented

Thanks for the detailed schema. I have populated with data and done tests.

Via Gremlin traversal API I have not been able to restrict the traversal queries to just hit the edge table. In addition, I had to create a materialized view in order to be able to search by the property acknowledged. The profile below shows you the traversal and which tables are being hit by the traversals. Both the MV on the edge and the Event vertex table are used to answer this query.

gremlin> g.E().hasLabel("WithEvent").has("acknowledged", true).and(__.inV().has("tenantId", "tenant2").has("eventCategory", "event1").has("createTime", gte('2009-10-23T10:15:30.00Z' as Instant))).profile()
==>Traversal Metrics
Step                                                               Count  Traversers       Time (ms)    % Dur
=============================================================================================================
__.E().hasLabel("WithEvent").has("acknowledged"...                     1           1           1.707    45.90
  CQL statements ordered by overall duration                                                   0.458
    \_1=SELECT * FROM community_5076."Account__WithEvent__Event_by_acknowledged" WHERE acknowledged = ? / Dur
        ation: < 1 ms / Count: 1 / Index type: Materialized view
HasStep([~label.eq(WithEvent), acknowledged.eq(...                     1           1           0.077     2.08
AndStep([[__.inV().has("createTime",P.gte(java....                     1           1           1.549    41.67
  __.inV().has("createTime",P.gte(java.time.Ins...                     1           1           1.316
    CQL statements ordered by overall duration                                                 0.364
    \_1=SELECT * FROM community_5076."Event" WHERE "tenantId" = ? AND "createTime" = ? AND "eventCategory" =
          ? AND gid = ? / Duration: < 1 ms / Count: 1 / Index type: Table: Event
  HasStep([tenantId.eq(tenant2), eventCategory....                                             0.038
ReferenceElementStep                                                   1           1           0.384    10.35
                                            >TOTAL                     -           -           3.719        -
gremlin>

I now understand what you mean by not being able to use the partitioning keys (from OUT vertex) through Tinkerpop, as you cannot specify them in the has() filters on the edge. If you include them explicitly as edge properties, or more properties from the IN vertex, as in your example, you would likely need a search index to search the edge table for all these criteria to satisfy your query.

3 comments Share
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

baid_manish_187433 avatar image baid_manish_187433 commented ·

Thanks for the quick response.

So, an edge query cannot be performed unless MV or search-indexes are created - there is no way to provide the partitioning key through gremlin.

Listing attribute-to-search-by as clustering key, like following would not help.

 schema.edgeLabel('WithEvent').
     ifNotExists().
     from('Account').to('Event')
     clusterBy('acknowledged', Boolean)

May be this can be improved in future.

0 Likes 0 ·
baid_manish_187433 avatar image baid_manish_187433 commented ·

Thanks for the quick response.

So, an edge query cannot be performed unless MV or search-indexes are created - since there is no way to provide the partitioning key through gremlin.

Listing attribute-to-search-by as clustering key, like following would not help.

 schema.edgeLabel('WithEvent').
     ifNotExists().
     from('Account').to('Event')
     clusterBy('acknowledged', Boolean)

May be this can be improved in future.

0 Likes 0 ·
bettina.swynnerton avatar image bettina.swynnerton ♦♦ baid_manish_187433 commented ·

Have you thought about querying the edge table directly through CQL? With the new edge table layout in Graph 6.8 this could perhaps be an alternative?

0 Likes 0 ·