Reputation: 81
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.
Upvotes: 0
Views: 506
Reputation: 81
@cybersam thank you for your answer. I did not try yours but I also just solved this on my own (after days of trying). My syntax is as follows:
// Contact1 is my source table. Contact2 is my destination table
MATCH (a:Contact1) WITH a.FirstName AS A
CALL apoc.index.search("Contact2", "Contact2.FirstName:" + A + "~")
YIELD node, weight RETURN *
I am not sure if that is the best way but it worked for me
Upvotes: 0
Reputation: 66989
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)
...
Upvotes: 1