[Xapian-discuss] Searching date range on a custom field

Matt Barnicle mattb at wageslavery.org
Thu May 31 23:12:18 BST 2007


Hi everyone.  I'm getting closer to getting our site indexed properly, 
but I can't figure out the date searching question..  I've read as many 
things as I can find, but I'm not quite getting the picture of what I 
have to do in order to be able to search on a date custom field.  I 
created our event pages with the following meta tags:

<meta name="dateBegin" content="20070210" />
<meta name="dateEnd" content="20070217" />

These correspond to the start and end dates of an event.  I also have a 
tag for when the rendered page is an event (we have many types of pages 
on the site):

<meta name="pageType" content="event" />

So, I need to search on events given a date.  Say the date is 20070213, 
how do I search for event pages where the supplied date is within the 
dateBegin .. dateEnd range?

I'm using htdig to crawl the site, and htdig2omega to create the index.  
The index creation and field mapping works just fine, and so does 
searching on the boolean page type.  Here is my htdig2omega.script file:

url : field=url hash boolean=Q unique=Q
title : weight=3 index truncate=80 field=title
lastMod : field=lastmod
size : field=size
sample : index truncate=300 field=sample
metaDesc : field=metadesc index
pageType : field=pageType boolean=XPT
eventName : field=eventName weight=3 index
dateBegin : field=dateBegin date=yyyymmdd
dateEnd : field=dateEnd date=yyyymmdd
city : field=city weight=3 index
state : field=state weight=3 index
zip : field=zip weight=3 index

I found some posts from the list archives that discuss date ranges, but 
I can't figure out if they will help me in this situation or not..  I 
think they're talking about searching on date ranges on indexed 
documents, that is, the date the document was indexed.

http://article.gmane.org/gmane.comp.search.xapian.general/1008
http://article.gmane.org/gmane.comp.search.xapian.general/4268


So, what do I need to do??  Thank you!

- Matt



More information about the Xapian-discuss mailing list