douwendu2460
douwendu2460
2014-09-29 07:52
浏览 105
已采纳

如何在Neo4j中进行精确的单词匹配?

In Neo4j, we can do mysql query "like" with

ex. If node "temp" have column "col" and value "This was in World war 1945";

If we search by "wor"

and where query is

temp.col =~  '(?i).*'. $search_value . '.*'

Then results are coming. But I want results to come only when searched for world with any case change.

How to do exact word match?

i.e. If we search for string then there should be space or no any character at start and end of word.

图片转代码服务由CSDN问答提供 功能建议

在Neo4j中,我们可以使用进行mysql查询“like” n

ex。 如果节点“temp”有列“col”和值“这是在1945年的世界大战中”;

如果我们搜索“wor”

并且查询位于

  temp.col =〜'(?i  )。*”。  $ search_value。  '。*'
   
 
 

然后结果即将到来。 但我希望只有在搜索任何案例变化的世界时才能得到结果。

如何进行精确的单词匹配?

即。 如果我们搜索字符串,那么在单词的开头和结尾应该有空格或没有任何字符。

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongqixian8474
    dongqixian8474 2014-09-29 08:11
    已采纳
    =~ '(?i).*'. $search_value . '.*'
    

    =~ = Regex search (?i) = case insenstive .* = Match anything $search_value = Your string .* = Match anything

    If you want to match whole words, and you want to match the case, and if that whole word can appear mid sentence then you could try:

    =~'.*\\b' . $search_value . '\\b.*'
    

    \b is a word boundary matcher.

    Update: "\\b" double slashes are required to escaping in for regular expressions.

    点赞 评论

相关推荐