I have a Janusgraph database with the following schema:
(Journal)<-[PublishedIn]-(Paper)<-[AuthorOf]-(Author)
I'm trying to write a query using the gremlin match()
clause that will search for two different journals and the related papers with a keyword in the title and the authors. Here's what I have so far:
sg = g.V().match(
__.as('a').has('Journal', 'displayName', textContains('Journal Name 1')),
__.as('a').has('Journal', 'displayName', textContains('Journal Name 2')),
__.as('a').inE('PublishedIn').subgraph('sg').outV().as('b'),
__.as('b').has('Paper', 'paperTitle', textContains('My Key word')),
__.as('b').inE('AuthorOf').subgraph('sg').outV().as('c')).
cap('sg').next()
This query runs successfully but returns 0 vertices and 0 edges. If I divide the query into two and search for each Journal displayName separately I get complete graphs, so I assume there's something wrong with the logic/syntax of my query.
If I write the query this way:
sg = g.V().or(has('JournalFixed', 'displayName', textContains('Journal Name 1')),
has('JournalFixed', 'displayName', textContains('Journal Name 2'))).
inE('PublishedInFixed').subgraph('sg').
outV().has('Paper', 'paperTitle', textContains('My Key word')).
inE('AuthorOf').subgraph('sg').
outV().
cap('sg').
next()
It returns a network with around 7000 nodes. How can I re-write this query to use the match()
clause?