I wanted to make use of the Neo4j Cypher apoc.index.search
procedure. I am currently using the Neo4j CE 3.1.0. I have successfully set up and tested the procedure as a stand-alone query such as:
call apoc.index.search("Contact2", "Contact2.FirstName:monica~")
Now, I want to do a MATCH
query first to fetch a set of nodes, and spool the FirstNames
found into calling this APOC procedure on Contact2
node to see if I can find any similar in the Contact2
node and the corresponding weight.
Is that possible? I have tried several iterations using the WITH
keyword but to no avail. Thanks.
You can add each firstName
value as separate fuzzy search terms to the query string passed to apoc.index.search
. For example:
MATCH (f:Foo)
WITH REDUCE(
s = 'Contact2.FirstName:', n IN COLLECT(DISTINCT f.firstName) |
s + n + '~ '
) AS query
CALL apoc.index.search("Contact2", query)
...