0

I am trying to paginate which works for the most part, but it breaks because of the fts.maxResults (If it is set too small, it won't return anything). What's the reason behind this?

limit = 1
offset = 1

# This returns nothing
g.withSideEffect(
    "Neptune#fts.endpoint", f"{url}"
)
.withSideEffect("Neptune#fts.queryType", "query_string")
.withSideEffect("Neptune#fts.maxResults", limit) # if i set this to limit+1, I get 1 result as expected
.withSideEffect("Neptune#enableResultCache", enable_cache)
.withSideEffect("Neptune#fts.sortOrder", "DESC")
.V()
.hasLabel("table")
.has(
    "*",
    f"Neptune#fts entity_type:"table" AND ({query})",
)
.range(offset, limit + offset)
Danny
  • 244
  • 3
  • 14

1 Answers1

0

The range() step in Gremlin is 0 based so with the query you are writing you will return a single result and then look for the second result in the array. Can you try setting the offset=0 and see if you are getting the expected results.

bechbd
  • 6,206
  • 3
  • 28
  • 47
  • Based on the documentation (below) I should be able to do .range(0,1) to get the first result, then .range(1, 2) to get the second result. If I set the offset to 0 it will return the first result (since it gives .range(0, 1)) but I want .range(1, 2) which doesn't work for some reason. Note that everything behaves as expected if I remove the fts.maxResults. https://docs.aws.amazon.com/neptune/latest/userguide/gremlin-results-cache.html – Danny Dec 19 '21 at 23:54
  • 1
    Setting fts.maxResults will specify the number of results returned from the FTS integration. This integration acts as sort of a barrier step which means each result from the FTS search will then be a separate traverser which will then be passed along to the range() step. In your case you are returning only a single result from FTS which means that your request for range(1,2) is asking for the second result from a list of traversers which only contains one result. Either removing or changing the fts.maxResults to a larger number will allow you to return the additional results. – bechbd Dec 20 '21 at 03:58
  • Gotcha, I had a check and this seems to be the case. The maxResults I set is the one that is causing the behaviour since the result of it gets passed to range() (e.g. limit = 100 will return 20 results, but limit=5 will return 1 result) – Danny Dec 20 '21 at 05:21