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

如何在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.

  • 写回答

1条回答 默认 最新

  • 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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 模电中二极管,三极管和电容的应用
  • ¥15 关于模型导入UNITY的.FBX: Check external application preferences.警告。
  • ¥15 气象网格数据与卫星轨道数据如何匹配
  • ¥100 java ee ssm项目 悬赏,感兴趣直接联系我
  • ¥15 微软账户问题不小心注销了好像
  • ¥15 x264库中预测模式字IPM、运动向量差MVD、量化后的DCT系数的位置
  • ¥15 curl 命令调用正常,程序调用报 java.net.ConnectException: connection refused
  • ¥20 关于web前端如何播放二次加密m3u8视频的问题
  • ¥15 使用百度地图api 位置函数报错?
  • ¥15 metamask如何添加TRON自定义网络