Neo4j - Order by relevance

醉酒当歌 提交于 2019-12-06 05:36:01

How about doing something like this in Cypher

MATCH (n:PROD) 
WHERE n.name_lc CONTAINS toLower({textToSearch})
WITH n, SPLIT(n.name_lc, toLower({textToSearch})) as parts
RETURN n.name, SIZE(parts[0]) AS leading
ORDER BY leading

To make effective use of the above...

Create an index on a lowercase version of the property

CREATE INDEX ON :PROD(name_lc)

Copy the regular name to a lowercase version

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