1

我正在尝试检索描述中包含“Art”一词的所有 BISAC 节点。

ba = Bisac.where(bisac_value =~ '.*Art.*')
NameError: undefined local variable or method `bisac_value' for main:Object

等效的密码查询检索 10 个节点。

MATCH (b:Bisac) WHERE (b.bisac_value =~ '.*Art .*') RETURN b;

我在这里做错了什么?

4

3 回答 3

1

您的解决方案肯定会起作用,但不使用QueryAPI 的更简单的解决方案是简单地使用 Ruby 正则表达式:

Bisac.all(:l).where(bisac_value: /.*Art.*/)

您甚至可以使用不区分大小写的正则表达式 ( /.*Art.*/i),它也会被翻译成 Cypher 语法。

于 2015-08-17T20:43:06.747 回答
0

从分页中移除 Kaminari 并使用 will_paginate。使用的 page_entries_info

问题解决了。

于 2015-08-19T18:49:44.957 回答
0

Found the answer (in the documentation), here is the link: http://neo4jrb.readthedocs.org/en/5.1.x/Querying.html

The query should be:

ba = Bisac.all(:l).where("l.bisac_value =~ {the_value}").params(the_value: '.*Art.*').pluck(:l)

or, much simpler:

ba = Bisac.all(:l).where("l.bisac_value =~ '.*Art.*'").pluck(:l)
于 2015-08-17T20:20:23.320 回答