>我在solr集合中有多个值字段"createddate",具有以下值
createddate : [
"1:2014-08-08T18:36:47Z",
"2:2014-08-08T18:37:07Z",
"3:2014-08-08T18:37:31Z",
"14:2015-07-29T16:56:29Z",
"16:2015-09-21T12:25:43Z",
"30:2015-11-30T08:00:00Z"
]
记录中的值类似于键:日期现在我想获取创建日期小于用户指定的当前日期和键(如 1 或 2 或任何
)的记录like created_date <= NOW()
我不知道我应该怎么做。 我希望 Solr 查询来执行此操作。
用你的对象尝试以下操作:
var result = [];
$.each(createddate, function(i, dateString){
var currentDate = new Date();
var currentDay = currentDate.getDay();
var suppliedDate = new Date(dateString);
var suppliedDay = suppliedDate.getDay();
if(suppliedDay < currentDay){
result.push(dateString);
}
});
console.log(result);