How to limit on db.index.fulltext.queryNodes per label?

Hi Community

In order to reduce the workload on neo4j and communication between systems, I want to create fulltext search query on an index , that gets/returns only a limited number of results,.

Currently I'm using this query which is returning me all result ordered by score together with the small subgraph for each node:
CALL db.index.fulltext.queryNodes('index_name', 'search_for_this') YIELD node CALL apoc.path.subgraphAll(node, { minLevel: 0, maxLevel: 1 }) YIELD nodes, relationships
RETURN nodes, relationships

As a title of example. Suppose I have node labels Books and Movies and I search for the word "world". What I need is to make the search more efficient and get only the first 10 results for label Books and the first 10 for label Movie. Currently, if it happens that there are first 15 with Books, then the first 15 are retrieved. This has impact hen I have 3000 nodes.

Is there any way to limit this number of text matches and the number of nodes?

We use Neo4j version: 4.2.1 enterprise

You could create two indexes, one for books and one for movies.
And you can pass a limit config param to the queryNodes procedure call.

if you don't want to do that you can do two subquery calls one for each and filter by node label and return LIMIT 10 from the subquery