【问题标题】:neo4j lucene score is always 0.0neo4j lucene 分数始终为 0.0
【发布时间】:2015-03-25 01:34:22
【问题描述】:

我们正在尝试查找 lucene 分配给 neo4j 查询结果的分数。

IndexManager index = graphDb.index();
Index<Node> fulltextMovies = index.forNodes("Restaurant");
QueryContext query = new QueryContext("name:" + term + "*");
TermQuery t = new TermQuery(new Term("name", term + "m*"));

IndexHits<Node> hits = fulltextMovies.query(t);
System.out.println(hits.currentScore());

代码的最后一行总是打印 0.0

我们是否必须定义自定义分数才能使其正常工作?据我了解,lucene 会为每个搜索结果分配一个分数。如果是这样,。我应该会根据我的查询结果看到一个 lucene 分数。这可能吗?

【问题讨论】:

    标签: java lucene neo4j


    【解决方案1】:

    您只能在使用索引查询中的迭代器时使用currentScore()。举个例子:

    try (IndexHits<Node> hits = index.query(t)) {
        for (Node node : hits) {
            System.out.println(node + " " + hits.currentScore());
        }
    }
    

    【讨论】:

    • 谢谢,斯特凡。我会尝试这个解决方案并更新这个线程。 :-)
    • 我尝试了你提到的步骤,但结果是一样的。我的所有搜索项现在都得到 0.0 分。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-02-28
    • 2016-10-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-28
    相关资源
    最近更新 更多