Search code examples
neo4jcyphertext-searchelasticsearch-phonetic

Can Cypher do phonetic text search with only a part of the text, without using elastic search?


Say I have a job as financial administrator (j:Job {name: 'financial administrator'}).

Many people use different titles for a 'financial administrator'. Therefore, I want abovementioned job as a hit, even if people type only 'financial' or 'administrator' and their input has typos (like: 'fynancial').

CONTAINS only gives results when the match is 100% - so without typos.

Thanks a lot!


Solution

  • It took a while, this is how I solved my question.

    MATCH (a)-[:IS]->(hs)
    UNWIND a.naam AS namelist
    CALL apoc.text.phonetic(namelist) YIELD value
    WITH value AS search_str, SPLIT('INPUT FROM DATABASE', ' ') AS input, a
    CALL apoc.text.phonetic(input) YIELD value
    WITH value AS match_str, search_str, a
    WHERE search_str CONTAINS match_str OR search_str = match_str
    RETURN DISTINCT a.naam, label(a)