cancel
Showing results for 
Search instead for 
Did you mean: 

Date range in lucene query

cperez
Champ in-the-making
Champ in-the-making
Hi all

I need to incorporate a lucene Serach for docs in a specified location on a particular date range (from fixed date to today less 1 hour). I have used the following lucene query but I get all the documents modified to the same moment as the query is executed.


var today = new Date();
//Start date
var sdate="2010\-01\-01T00:00:00";
//end date, today one hour early
var tdate=today.getFullYear()+"\-"+(today.getMonth()+1)+"\-"+today.getDate()+"T"+(today.getHours()-1)+":00:00";
//var spath="'+PATH:\""+aprobados.displayPath +"/\" + ";
var spath="+PATH:\"/app:company_home/cm:My_space/cm:testing//*\" +";
var scontent="@\\{http\\://www.alfresco.org/model/content/1.0\\}content.mimetype:image/tiff + ";
var qdate="@cm\\:modified:[" + sdate + " TO " + tdate +"]";
//var strq=spath+scontent+qdate;
var strq=spath+scontent+qdate;

// Do the search and save the vales
var nodes=search.luceneSearch(strq);


The problem: I don't want to get the document in the last hour like is defined in "qdate" (I use it in other querys wher I don't want the hour, but now it is necesary) but I get all the document to exute moment.

How can i solve it??
Thanks a lot in advance
4 REPLIES 4

cperez
Champ in-the-making
Champ in-the-making
Sorry, but I don't understand you.

My range query is :

@cm:modified:["2010-00-01T00:00:00" TO "2014-09-24T10:00:00"]

But I get documents modified out of that range (for example,modified at 2014-09-24T11:35:00).

cperez
Champ in-the-making
Champ in-the-making
I find in http://blogs.alfresco.com/wp/developer/2011/02/01/whats-in-a-date/ that by default the indexes only works with years, months and days. And is necesary to active hour and minutes to be indexed.

Is this correct??

I search in my server that file "alfresco/model/dataTypeAnalyzers.properties", but that not exist because I have a document for each language (like " /opt/Alfresco/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/model/dataTypeAnalyzers_en.properties") and their content not include that line

"d_dictionary.datatype.d_datetime.analyzer=org.alfresco.repo.search.impl.lucene.analysis.DateTimeAnalyser"


I need to add that line to the file with the language I use and restart alfresco indexes??

can you explain me how to do it in my Alfresco 3.0??

Thanks

kaynezhang
World-Class Innovator
World-Class Innovator
It seems the solution in this post only works after alfresco community 3.3.
Your alfresco version is a little old,maybe upgrading to a newer version is a better solution.Since alfresco 4 you don't need any additional configuration,the solr search system by default uses the date time analyzer for d:datetime.