我试图使用modeshape进行全文搜索。我对基于lucene指数的排名结果特别感兴趣。这是我的存储库配置
"indexProviders": {
"lucene": {
"classname": "lucene",
"directory": "${user.home}/repository/indexes"
}
},
"indexes": {
"textFromFiles": {
"kind": "text",
"provider": "lucene",
"nodeType": "nt:resource",
"columns": "jcr:data(BINARY)"
}
},
我注意到在指定位置创建了一个lucene索引。我将10-15个带有不同出现的搜索词的filesc添加到存储库中,并尝试使用一些单词进行搜索。我打印得分如下所示
QueryManager querymgr = session.getWorkspace().getQueryManager();
String query = "SELECT file.* FROM [nt:hierarchyNode] as file LEFT JOIN [nt:resource] as data ON ISCHILDNODE(data , file) WHERE "
+ "contains(data.*, '" + searchText + "')";
Query createQuery = querymgr.createQuery(query, Query.JCR_SQL2);
QueryResult result = createQuery.execute();
RowIterator rows = result.getRows();
while(rows.hasNext()){
Row nextRow = rows.nextRow();
LOGGER.info("score : {}", nextRow.getScore());
}
但是,所有结果的分数始终为1.0。 还尝试了一个更简单的查询而没有加入...
SELECT data.* FROM [nt:resource] as data WHERE contains(data.*, 'searchterm')
但没有运气