Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
11-11-2019 03:58 AM
When a user search for boat
, it doesn't yield results containing yacht
and ship
, don't go any further, I explain everything you need to know in this blog post
https://dev.to/ikwattro/handling-synonyms-in-neo4j-full-text-search-232p
11-11-2019 04:15 AM
Nice post indeed.
I used graph-based synonyms for one customer in the past. Basically in the graph we store (:Word)-[:HAS_SYNONYM]->(:Word)
. When resolving synonyms a cypher query resolves them. Eat your own graph food.
11-11-2019 04:36 AM
Yes, I go over that technique in my Nodes 19 talk : https://www.bigmarker.com/neo4j/full-text-search-tips-to-be-or-not-to-be?bmid=953a7644b875
Here are the queries used
// Show Synonyms
MATCH p=(n:Syn)-[:ALIAS]->(o) RETURN p
// How to build synonyms
WITH '"lucene"' AS query
UNWIND split(replace(query, "\"", ""), " ") AS token
MATCH (n:Syn {value: token})-[:ALIAS]-(a)
RETURN replace(query, token, a.value)
// Generate synonyms query
WITH '"lucene"' AS query
UNWIND split(replace(query, "\"", ""), " ") AS token
MATCH (n:Syn {value: token})-[:ALIAS]-(a)
WITH collect(replace(query, token, a.value)) + query AS coll
WITH [x IN coll | "(" + x + ")"] AS coll
RETURN apoc.text.join(coll, " OR ")
// Make search with generated synonyms query
WITH '"lucene"' AS query
UNWIND split(replace(query, "\"", ""), " ") AS token
MATCH (n:Syn {value: token})-[:ALIAS]-(a)
WITH collect(replace(query, token, a.value)) + query AS coll
WITH [x IN coll | "(" + x + ")"] AS coll
WITH apoc.text.join(coll, " OR ") AS finalQuery
CALL db.index.fulltext.queryNodes('nodes19', 'topic: ' + finalQuery)
YIELD node, score
RETURN node, score
11-11-2019 06:52 AM
Thanks for submitting!
I've added a tag that allows your blog to be displayed on the community home page!
All the sessions of the conference are now available online