【问题标题】:Why does Neo4j index query return no results on linux while the same query returns results on macOS?为什么 Neo4j 索引查询在 linux 上没有返回结果,而在 macOS 上相同的查询返回结果?
【发布时间】:2013-11-11 22:30:21
【问题描述】:

我有一个使用 Jruby 并嵌入了 neo4j 数据库的 Rails 应用程序。在 MacOS 10.8.5 下开发时,使用 Jruby 1.7.4 (JDK 1.7.0),在通过 ActiveRecord 验证后,我发出了一个索引查询以检索具有键值对“name:bento && type:services”的节点该节点确实存在。

当我在 CentOS 6.4 上运行相同的序列时,索引查询没有返回任何结果。

我的问题是,为什么我的索引查询不能在 CentOS 6.4 上运行,而在 MacOS 10.8.5 上运行?

这是 MacOS 的控制台会话记录,然后是 CentOS 的记录:

================================================ =====

[On MacOS 10.8.5, using Jruby 1.7.4 (JDK 1.7.0), using Neo4j Community 1.9.1]

irb(main):001:0> # verify that node with name: bento && type: services exists

irb(main):002:0> Vertex.all.select{|v| v.name == "bento" && v.type=="services"}[0].name
=> "bento"
irb(main):003:0> Vertex.all.select{|v| v.name == "bento" && v.type=="services"}[0].type
=> "services"

irb(main):004:0> # Attempt to retrieve that same node using Neo4j Lucene Index Manager

irb(main):005:0> thisgraph =  Neo4j.db.graph
=> #<Java::OrgNeo4jKernel::EmbeddedGraphDatabase:0x662a6d5b>
irb(main):006:0> index_manager = thisgraph.index
=> #<Java::OrgNeo4jKernel::IndexManagerImpl:0x77a89d44>
irb(main):007:0> node_exact_index_manager = index_manager.for_nodes("Node_Exact")
=> #<Java::OrgNeo4jIndexImplLucene::NodeIndex:0xb55bed2>
irb(main):008:0> service = node_exact_index_manager.query("name: bento && type: services").getSingle()
=> #<Java::OrgNeo4jKernelImplCore::NodeProxy:0x2666829a>
irb(main):009:0> service[:name]
=> "bento"
irb(main):010:0> service[:type]
=> "services"

===========================
[On CentOS 6.4, using Jruby 1.7.4 (JDK 1.7.0), using Neo4j Community 1.9.1 ]
# verify that node with name: bento && type: services exists
irb(main):008:0> Vertex.all.select{|v| v.name == "bento" && v.type=="services"}[0].name
=> "bento"
irb(main):009:0> Vertex.all.select{|v| v.name == "bento" && v.type=="services"}[0].type
=> "services"

# Attempt to retrieve that same node using Neo4j Lucene Index Manager

irb(main):011:0> thisgraph =  Neo4j.db.graph
=> #<Java::OrgNeo4jKernel::EmbeddedGraphDatabase:0x1acf245f>
irb(main):012:0> index_manager = thisgraph.index
=> #<Java::OrgNeo4jKernel::IndexManagerImpl:0x55fcebbe>
irb(main):013:0> node_exact_index_manager = index_manager.for_nodes("Node_Exact")
=> #<Java::OrgNeo4jIndexImplLucene::NodeIndex:0x20bcb45a>
irb(main):014:0> service = node_exact_index_manager.query("name: bento && type: services").getSingle()
=> nil

===========================

MacOS 和 CentOS 上的两个数据库和索引是相同的。为了更好地衡量,我使用 Luke 查看了两个索引(MacOS 上的一个和 CentOS 上的一个),并验证了我正在查询的节点确实可以使用查询字符串“name:bento && type:services”来检索。

[刚刚验证我们在 RedHat 上看到与在 CentOS 上相同的行为]

如果 CentOS 上的查询没有产生任何结果,我将不胜感激。谢谢。

【问题讨论】:

  • (我发现了问题;作为评论发布以绕过发布答案之前的 8 小时等待期要求):索引是 Node_exact,而不是 Node_Exact,它适用于 OSX,因为它显然是案例-不敏感。

标签: ruby-on-rails macos lucene neo4j centos6


【解决方案1】:

获取节点索引的语句使用“Node_Exact”作为索引名参数。

node_exact_index_manager = index_manager.for_nodes("Node_Exact")

实际的索引名为 Node_exact,带有小写的 e。 OsX 显然将索引名称视为不区分大小写,而对于 Linux(CentOS 和 RedHat 风格)则不是这种情况。

将索引名称参数更正为“Node_exact”后,结果正确显示。

node_exact_index_manager = index_manager.for_nodes("Node_exact")

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-07-12
    • 2016-11-18
    • 1970-01-01
    • 1970-01-01
    • 2020-09-24
    • 1970-01-01
    • 2016-08-22
    • 2015-02-25
    相关资源
    最近更新 更多