0

I'm implementing a graph database on ASWS Neptune and I'm using as well AWS OpenSearch to allow me perform a full text search.

I want to get all the child vertex that match a property. (In this case get all documents)

I did the following:

g.V( folderId )
 .emit()
 .repeat( in().dedup() )
 .in()
 .hasLabel( "document" )
 .valueMap()
 .by( unfold() )
 .toList();

This will return all documents that are in that folder and sub-folders as well.

Now I did this to only return the documents that are in that folder/subfolder that match a name.

g.withSideEffect( "Neptune#fts.endpoint", "..." )
 .V( folderId )
 .has( "name", "Neptune#fts " + name + "*" )
 .emit()
 .repeat( in().dedup() )
 .in()
 .hasLabel( "document" )
 .valueMap()
 .by( unfold() )
 .toList();

It returns a empty result but if I remove the folderId it returns all the documents that match that name.

Any way to only return the ones that match the name and are on that folder?

Thanks

kylie.zoltan
  • 377
  • 3
  • 15

1 Answers1

0

Without some sort of sample data it is hard to give you a query that will satisfy your requirements but the likely reason you are getting an empty result is that you are not traversing to any child records to apply your name search. Let's look at this section of the query:

g.withSideEffect( "Neptune#fts.endpoint", "..." )
 .V( folderId )
 .has( "name", "Neptune#fts " + name + "*" )

This is saying "Find me a vertex with an id=folderId and a name like name*. This will only return a value if both of these conditions are true, which I suspect are not in this scenario.

If you are looking to find all child documents for a specific vertex id that start with name* then you will want to do something more like:

g.withSideEffect( "Neptune#fts.endpoint", "..." )
 .V( folderId )  //Find a vertex with folderId
 .emit() //Emit the vertices
 .repeat( in().dedup()) //Repeatedly go out the in edges until there are no more
 .hasLabel( "document" ) //Filter to only document labels
 .has( "name", "Neptune#fts " + name + "*" ) //Filter to find things with "name*"
 .valueMap()
 .by( unfold() )
 .toList();

Additionally, due to how Neptune indexes data (here) will perform better if you can specify the label(s) for the in() edges such as in('parent').

bechbd
  • 6,206
  • 3
  • 28
  • 47