cancel
Showing results for 
Search instead for 
Did you mean: 

Attributes in Lucene date range

erik_kirs
Champ in-the-making
Champ in-the-making
Hi,

is it possible to use attributes and expressions in Lucene date range query? Using only cm:created and cm:modified attributes I need to fetch documents which have not been modified 15 days, f ex. Is it possible to do only with one Lucene query string?

Thanks in advance.
10 REPLIES 10

kevinr
Star Contributor
Star Contributor
Currently I think only date ranges can be searched - but that should cover your case.
http://wiki.alfresco.com/wiki/Search#Range_Queries

Kevin

andy
Champ on-the-rise
Champ on-the-rise
Hi

Full timestamp support will probably be available in the next community release.

Andy

daniel_robert
Champ in-the-making
Champ in-the-making
We're running "Version: Enterprise Network - v2.0.1" and ran across this as a problem.  We were looking for the ability to search between the times to items in our repository were originally published.   It was a bit misleading at first that the Alfresco UI supports date/time in searches (and builds a corresponding date range when saving the search), and a little digging to find that a range of [2007-11-21T17:25:00 TO 2007-11-22T15:30:00] was reduced to [2007-11-21 TO 2007-11-22]. We ended up digging when we discovered that including the time zone (a necessary part of date ranges to us) caused a parsing exception.

Andy: to follow up with your most recent comment in this thread: this is a probable fix in an upcoming version?  I'm curious if there are any workarounds, or simple extensions points to the query parser to allow converting the time properties to timestamps (or other, more specific time formats) before passing them to lucene.  We looked at some of the parser code, but it all seemed to be JavaCC-built and not easily extensible.

andy
Champ on-the-rise
Champ on-the-rise
Hi

It is possible to configure indexing to include time (and not just date as it does now) in later versions. It is not done by default as you would have to do full reindex.

The query side is not looking at timezones and is expecting queries in the correct time zone (that of the server).

It is possible to fix this up in the LuceneQueryParser class which can be used to customize the JavaCC parse.

Andy

kdejaeger
Champ in-the-making
Champ in-the-making
I discovered yesterday in the 2.1 release that a query with a datarange like "[2007-11-21 TO 2007-11-22]", does not parse anymore. It seems you have to include the time details, as instructed on this page : http://wiki.alfresco.com/wiki/Search#Range_Queries.

There is a usefull class in alfresco-core which can easily parse this dateformat : ISO8601DateFormat.
I ended up with code like this :
            String sFromDate = ISO8601DateFormat.format(DATEFORMAT_yyyyMMdd.parse(request.getParameter(PARAM_FROM_EMISSION_DATE)));
            String sToDate = ISO8601DateFormat.format(new Date());

bpinnovators
Champ in-the-making
Champ in-the-making
Andy,

In your Dec 10, 2007 post you state:
———————————————————
It is possible to configure indexing to include time (and not just date as it does now) in later versions.
———————————————————

That is great. Can you please provide a link or other hint as to the whereabouts of documentation on making this modification? We are running 2.1.3 enterprise.

Bob

andy
Champ on-the-rise
Champ on-the-rise
Hi

In dataTypeAnalyzers.properties
you need to change

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

to

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

and rebuild your indexes.

Andy

abirb
Champ in-the-making
Champ in-the-making
I need to incorporate a lucene Serach for docs in a specified location on a particular date range. I have used the following lucene query , but it throws up an error in the response file

500 Description: An error inside the HTTP server which prevented it from fulfilling the request. 
  
Message: Error during processing of the template 'Expression resultset is undefined on line 7, column 8 in SearchDate.post.html.ftl.'. Please contact your system administrator.

the controller file (lucene search)
var nodes = search.luceneSearch("date:\" [2008\-10\-30T00:00:00 TO 2008\-10\-30T00:00:00]);
model.resultset=nodes;

the Response file
<
html>
  <body>
    <img src="${url.context}/images/logo/AlfrescoLogo32.png" alt="Alfresco" />
    Date Searched for : PUT THE DATES HERE
    <br>
    <table>
<#list resultset as node>
     <tr>
       <td><img src="${url.context}${node.icon16}"/>
       <td><a href="${url.serviceContext}/api/node/content/${node.nodeRef.storeRef.protocol}/${node.nodeRef.storeRef.identifier}/${node.nodeRef.id}/${node.name?url}">${node.name}</a>
     </tr>
</#list>
    </table>
  </body>
</html>

brunyan
Champ in-the-making
Champ in-the-making
Hello,

I have a proper tie date, and i want to use lucene to find a day like this @cm\:modified:"2006-07-20"  but isn't working, I have tried this @cm\:modified:"2006-07-20T00:00:00.000Z" but doesn't work to.

I can only find a day using range query like this @cm\:modified:[2006-07-20T00:00:00.000 TO @cm\:modified:"2006-07-20T23:59:59.999]!

This is correct??