按日期对Google自定义搜索结果进行排序

问题描述

| 我正在迁移Google自定义搜索引擎,以使用CustomSearchControl替换不推荐使用的WebSearch API,其中一项要求是按日期对建议结果进行排序。但是到目前为止,我还不知道如何在返回建议之前告诉Google按最新日期对结果进行排序。示例代码如下:
var refinement=\"Support\";
.....
switch(product)
{
    case \"10000\":
        refinement = \"Support1\";
        break;
    case \"10002\":
        refinement = \"Support1\";
        break;
    case \"10001\":
        refinement = \"Support2\";
        break;
    default:
        break;
}

var customSearchControl = new google.search.CustomSearchControl(\'cseId\');
customSearchControl.setSearchStartingCallback(this,function(control,searcher,query) {
    searcher.setQueryAddition(\'more:\' + refinement);
});

customSearchControl.setResultSetSize(7);
customSearchControl.draw(\'entries\');
......
我已经尝试过使用新近度标签对结果进行排序,但是它不起作用:
customSearchControl.setSearchStartingCallback(this,query) {
    //searcher.setQueryAddition(\'more:recent3\');
    searcher.setQueryAddition(\'more:\' + refinement + \',more:recent3\');
});
而且我还尝试了按属性排序,但是它也不起作用:
var options = {};
options[google.search.Search.RESTRICT_EXTENDED_ARGS] = {\'sort\': \'date-sdate:d:s\'}; //Tried to use other date format but it doesn\'t help

var customSearchControl = new google.search.CustomSearchControl(\'cseId\',options);
也许按属性排序将不起作用,因为我们的Web文档中没有声明属性。因此,还有其他方法可以让我们告诉Google按日期对搜索结果进行排序吗?     

解决方法

        我遇到以下问题: http://code.google.com/intl/nl-NL/apis/customsearch/docs/js/cselement-reference.html
options[google.search.Search.RESTRICT_EXTENDED_ARGS] = {
  \'lr\': \'lang_it\',\'sort\': \'date\'
};
var customSearchControl = new google.search.CustomSearchControl(id,options);
希望如果问题仍然存在,将对您有所帮助。     

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...