cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Full-text search skip and limit

chrszrkl
Node Clone

I need to limit the search results returned by a full-text search based on an offset and limit. That means, the first query would return the first 10 results (offset=0, limit=10) and a second query would return the next 10 results (offset=10, limit=10).

My current query uses apoc.agg.slice() to slice the result set accordingly:

CALL db.index.fulltext.queryNodes($index, $searchQuery) YIELD node, score
WITH apoc.agg.slice({node: node, score: score}, $offset, $limit) as records
RETURN collect({node: node, score: score}) as records

However, I was checking the Java implementation for db.index.fulltext.queryNodes() and noticed that there is a third parameter options which allows skip and limit

CALL db.index.fulltext.queryNodes($index,$searchQuery,{skip: 0, limit: 10})

This parameter seems to not be officially documented on the full-text search manual.

Therefore, my two questions are:

  1. 1. What's the official recommendation by Neo4j?
  2. 2. Is there a performance difference between apoc.agg.slice() and the passing options as 3rd parameter?

 

 

1 ACCEPTED SOLUTION

steggy
Neo4j
Neo4j

Hi @chrszrkl 

Good catch. We will get this updated in the docs. This should be more performant than the apoc option, as it can push the filtering into Lucene.

edit: it's here: https://neo4j.com/docs/operations-manual/current/reference/procedures/#procedure_db_index_fulltext_q...

J

View solution in original post

2 REPLIES 2

steggy
Neo4j
Neo4j

Hi @chrszrkl 

Good catch. We will get this updated in the docs. This should be more performant than the apoc option, as it can push the filtering into Lucene.

edit: it's here: https://neo4j.com/docs/operations-manual/current/reference/procedures/#procedure_db_index_fulltext_q...

J

Great, that makes the pagination for search results a little easier!

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

All the sessions of the conference are now available online