Alfresco弹弓搜索号码和总记录号不同

时间:2015-06-26 02:57:32

标签: search numbers alfresco totals

首先抱歉我的英语。

我正在使用Alfresco 5.0.d

我在搜索json结果(使用firebug控制台面板)中看到,除了结果项之外,还返回了2个其他属性:numberFound和totalRecords。似乎Alfresco默认的搜索引擎认为numberFound是找到的总项目。所以它显示" numberFound结果成立"给用户。

问题是numberFound不等于totalRecords。

我看到totalRecords是正确的搜索结果数(实际上搜索总是返回" totalRecords"项目数)。

所以我决定在webscript中看到执行搜索(alfresco-remote-api-5.0.d.jar \ alfresco \ templates \ webscripts \ org \ alfresco \ slingshot \ search \ search.lib.js)。我们可以很容易地看到" numberFound"财产来自这个声明

var rs = search.queryResultSet(queryDef);
var numberFound  = rs.meta.numberFound ;

关于" totalRecords"属性,它来自相同的声明,但有点不同:

var totalRecords = rs.nodes.length 这是真正找到的项目数的正确值。

这是一个Alfresco api bug吗?

如果不是,错误是否可能来自我的查询参数?

有人可以解释一下numberFound属性是什么意思吗?

谢谢。

1 个答案:

答案 0 :(得分:1)

以下是执行search.queryResultSet(queryDef)代码时调用的java文件的URL。

你可以在java文件中参考下面的方法。它正在添加所有内容。

https://svn.alfresco.com/repos/alfresco-open-mirror/alfresco/HEAD/root/projects/repository/source/java/org/alfresco/repo/jscript/Search.java

public Scriptable queryResultSet()  //This is java method which is getting called.

以下是为您获得的结果编写的代码。

 meta:
    {
     numberFound: long, // total number found in index, or -1 if not known or not supported by this resultset
     facets: 
     {              // facets are returned for each field as requested in the SearchParameters fieldfacets 
        field: 
        {            // each field contains a map of facet to value
                    facet: value,
        },
     }
    }
相关问题