在neo4j中,我使用自定义分析器来构建lucene索引。但是,在索引中搜索时,某些查询结果会获得NaN分数。
源代码:
try (Transaction tx = Neo4j.graphDb.beginTx()) {
IndexManager index = Neo4j.graphDb.index();
/**query*/
Index<Node> addressNodeFullTextIndex = index.forNodes("NodeFullTextIndex",
MapUtil.stringMap(IndexManager.PROVIDER, "lucene", "analyzer", IKAnalyzer5x.class.getName()));
Query test = IKQueryParser.parseMultiField(fields, query);
IndexHits<Node> foundNodes = addressNodeFullTextIndex.query(test);
for(Node n : foundNodes){
Map<String, Object> m = n.getAllProperties();
m.put("score", foundNodes.currentScore());
log.info("method[selectByIndex] score<"+foundNodes.currentScore()+">");
ret.add(m);
}
tx.success();
} catch (IOException e) {
log.error("method[selectByIndex] fields<"+Joiner.on(",").join(fields)+"> query<"+query+">", e);
throw e;
}
这就是结果json:
[
{
"score":4.786232,
"knowledge_name":"信阳市科学技术局",
"knowledge_id":"baidubaike_4658797/4658797"
},
{
"score":1.4323579,
"knowledge_name":"信阳市人事局",
"knowledge_id":"baidubaike_4658842/4658842"
},
{
"score":NaN,
"knowledge_name":"信阳市农业局",
"knowledge_id":"baidubaike_4658885/4658885"
}
]
neo4j版本:3.1.0 Lucene版本:5.5.0
你可以看到一些得分代码获得NaN值,为什么?或者查询代码中有什么问题吗?