[opencms-dev] Filter search by date
Shi Yusen
shiys at langhua.cn
Fri Sep 22 17:53:35 CEST 2006
Hi Alessandro,
I assume what you want to search are in xmlcontent type.
1. You may write a java file extends
org.opencms.search.documents.CmsDocumentXmlContent, override public
Document newInstance(CmsObject cms, A_CmsIndexResource resource, String
language) throws CmsException {
...
/**
* date of creation and last modification should also affect the
boost factor
* modified by Shi Yusen, shiys at langhua.cn
*/
// add date of creation and last modification as keywords (for
sorting)
field = new Field(I_CmsDocumentFactory.DOC_DATE_CREATED,
DateTools.dateToString(
new Date(res.getDateCreated()),
DateTools.Resolution.MILLISECOND), Field.Store.YES, Field.Index.
UN_TOKENIZED);
// field.setBoost(0);
document.add(field);
field = new Field(I_CmsDocumentFactory.DOC_DATE_LASTMODIFIED,
DateTools.dateToString(new Date(
res.getDateLastModified()), DateTools.Resolution.MILLISECOND),
Field.Store.YES, Field.Index.UN_TOKENIZED);
// field.setBoost(0);
document.add(field);
...
}
2. Edit opencms-search.xml, change the xmlcontent class to yours.
<documenttype>
<name>xmlcontent</name>
<class>write your class here</class>
<mimetypes/>
<resourcetypes>
<resourcetype>*</resourcetype>
</resourcetypes>
</documenttype>
3. Deploy your class and restart your servlet engine.
Good luck,
Shi Yusen/Beijing Langhua Ltd.
--------------------------------------------------------------
Tel: 86-10-88514088, 88514099
Fax: 86-10-88514099
Email: shiys at langhua.cn
Website: http://www.langhua.cn/
--------------------------------------------------------------
-----邮件原件-----
发件人: opencms-dev-bounces at opencms.org [mailto:opencms-dev-bounces at opencms.
org] 代表 Alessandro Magnolo
发送时间: 2006年9月22日 21:11
收件人: The OpenCms mailing list
主题: [opencms-dev] Filter search by date
I need to be able to search for documents created/modified in a
certain date range.
I found many hints on the subject in this mailing list, but I'm still
unable perform a working search.
Here are my findings so far:
* org.opencms.search.CmsSearch javadoc states that "the following
fields are available for searching: [...] created, lastmodified
[...]". I included the fields in a jsp search query, but wasn't able
to make them work. What is the syntax to be used to specify a time
range?
I tried for example with lucene syntax "created:[20050422 TO
20060922]" and variations, but they don't work.
* using Luke to browse the opencms lucene indexes, I found that the
"created" and "lastmodified" fields are indeed indexed. Strangely,
even a query performed in Luke on these fields, with known matches,
returns nothing (I tried for example
"lastmodified:20060612141001000").
So, anybody knows how to find results in a date range?
Thank you,
Alessandro Magnolo
_______________________________________________
This mail is sent to you from the opencms-dev mailing list
To change your list options, or to unsubscribe from the list, please visit
http://lists.opencms.org/mailman/listinfo/opencms-dev
More information about the opencms-dev
mailing list