Someone knows how can I search for a node using the full-text query, but limited to a relationship with a specific node?
Here is an example that I had implemented, but stills too slow.
MATCH (n) WHERE id(n) = $id
WITH n
CALL db.index.fulltext.queryNodes('index_names', 'name1 AND name2')
YIELD node WHERE (n)-[]-(node)
WITH node, n
MATCH p=(n)-[r:SOME_RELATION]-(node)
RETURN p
SKIP 0 LIMIT 5
you might try the following (which does an hash-join on both)
MATCH (n)--(target) WHERE id(n) = $id
CALL db.index.fulltext.queryNodes('index_names', 'name1 AND name2') yield node
where node = target
MATCH p=(n)-[r:SOME_RELATION]-(node)
RETURN p
SKIP 0 LIMIT 5
if you run profile on this it should show two driving statements that are then joined with an hash-join.
I tried your implementation but continued too slow for me.
After some experiments, I find this as the best solution for me:
match (n) where id(n) = $id
CALL apoc.neighbors.athop(n, "SOME_RELATION", 1)
yield node
with collect(node) as node_neighbors
call db.index.fulltext.queryNodes("index_names", 'name1 AND name2')
YIELD node
with collect(node) as node_full_text, node_neighbors
return apoc.coll.intersection(node_full_text, node_neighbors)
I share this code here to help someone, someday... hehe