【发布时间】:2015-08-20 15:57:52
【问题描述】:
我这几天一直在尝试解决这个问题。
我想对全文进行START 查询,按相关性排序,以便对结果进行分页。
很高兴,我终于在全文索引和 Neo 上找到了这个帖子(并使用 python 作为驱动程序)。
[https://groups.google.com/forum/#!topic/neo4j/9G8fcjVuuLw]
我已经用批量超级导入器导入了我的数据库,并得到了@Michaelhunger 的回复,他注意到有一个错误,所有分数都会被导入相同的值。
所以,现在我正在重新创建索引,并通过 REST 检查分数 (&order=score)
http://localhost:7474/db/data/index/node/myInde?query=name:myKeyWord&order=score
并注意到条目的分数仍然相同。
(您必须执行 ajax 查询才能看到它,因为如果您使用 Web 控制台,您将看不到所有数据!!)
我的代码重新创建全文 lucene 索引,每个节点属性“名称”: (这里使用 neo4j-rest-client,但我也会尝试使用 py2neo,就像在 Google 讨论中一样):
from neo4jrestclient.client import GraphDatabase
gdb = GraphDatabase("http://localhost:7474/db/data/")
myIndex = gdb.nodes.indexes.create("myIndex", type="fulltext", provider="lucene")
myIndex.add("name",node.get("name"),node)
结果:
http://localhost:7474/db/data/index/node/myInde?query=name:DNA&order=score
data Object {id: 17062920, name: "DNA damage theory of aging"}
VM995:10 **score 11.097855567932129**
...
data Object {id: 17022698, name: "DNA (film)"}
VM995:10 **score 11.097855567932129**
在文档中: [http://neo4j.com/docs/stable/indexing-lucene-extras.html#indexing-lucene-sort] 据说 Lucene 本身的排序非常好,所以我理解它在导入时自己创建了一个排名;它没有。
我做错了什么或错过了什么?
【问题讨论】:
标签: neo4j lucene full-text-search py2neo neo4jrestclient