Neo4j: Lucene phrase matching using Cypher (fuzzy)

耗尽温柔 提交于 2019-12-18 09:12:23

问题


In Lucene, a Phrase is a group of words surrounded by double quotes such as "hello dolly". I would like to be able to do the CYPHER equivalent of this Lucene fuzzy query:

"hello dolly"~0.1

This finds my "hello dolly" node:

START n=node:node_auto_index("name:\"hello dolly\"~0.1") RETURN n

This doesn't:

START n=node:node_auto_index("name:\"hella dolly\"~0.1") RETURN n

Splitting the search phrase by whitespace into Single Terms does work:

START n=node:node_auto_index("name:hella~0.1 AND name:dolly~0.1") return n

However, my data might contain string like "HelloDolly" which I would like to have matched successfully with my "hello dolly" node.

EDIT:

Some other attempts:

START n=node:node_auto_index("name:hello\\ dolly") RETURN n ----> does work (finds my "hello dolly" node, but is not fuzzy

START n=node:node_auto_index("name:hello\\ dolly~0.00001") RETURN n ----> doesn't work (finds nothing)


回答1:


Try this one:

START n=node:node_auto_index("name:hella\\ dolly~0.1") RETURN n



回答2:


It's an old question but this may help others:

START n=node:node_auto_index('name:"hella dolly"~0.1') RETURN n


来源:https://stackoverflow.com/questions/25553998/neo4j-lucene-phrase-matching-using-cypher-fuzzy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!