ranked full text search results using Lucene with modeshape

独自空忆成欢 提交于 2019-12-06 07:23:34

问题


I'm trying to get full-text search working with modeshape. I'm particularly interested in ranked results based on lucene index. Here is my repository configuration

 "indexProviders": {
        "lucene": {
            "classname": "lucene",
            "directory": "${user.home}/repository/indexes"
        }
    },
    "indexes": {
        "textFromFiles": {
            "kind": "text",
            "provider": "lucene",
            "nodeType": "nt:resource",
            "columns": "jcr:data(BINARY)"
        }
    },

I noticed a lucene index created at the specified location. I added 10-15 filesc with varied number of occurrence of search term into repository, and tried searching using some words. I am printing the score as shown below

        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());
        }

But, here score is always 1.0 for all results. Also tried a simpler query without join...

SELECT data.* FROM [nt:resource] as data WHERE contains(data.*, 'searchterm') 

but no luck

来源:https://stackoverflow.com/questions/34060032/ranked-full-text-search-results-using-lucene-with-modeshape

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!