I am new to PyLucene. I am trying to use PyLucene to index Articles with
created time  stored as a datetime object.
After looking at Lucene documentation i tried to use this piece of code to
solve the issue but it doesn't solve the problem.

>>import PyLucene
>>lucenedt = PyLucene.Date()
>>lucenedt.setTime(long(time.mktime(created_on.utctimetuple()))*1000)
>>field = PyLucene.Field("pubdate", lucenedt ,PyLucene.Field.Store.YES,
PyLucene.Field.Index.UN_TOKENIZED)
>>doc.add(field)

I get PyLucene.InvalidArgsError exception.

I read on "Lucene in Action" Book by Otis Gospodnetic & Erik Hatcher in
section2.4(indexing dates) that storing date as string objects of type
'yyyymmdd' will solve the problem easliy. Though indexing completes with out
any problems. I am not able to search for the results based on time.

datestring = '%s%s%s' % (created_on.year,created_on.month,created_on.day)
field = PyLucene.Field("pubdate", datestring ,PyLucene.Field.Store.YES,
PyLucene.Field.Index.UN_TOKENIZED)

My Search string is like this.

searcher.search('Mike  and pubdate:[21/7/2007 TO 31/7/2007]')
The result set doesnot contain results from this range.  Any amount of help
is deeply appreciated.


Thanks in advance,

Saikrishna.
_______________________________________________
pylucene-dev mailing list
[email protected]
http://lists.osafoundation.org/mailman/listinfo/pylucene-dev

Reply via email to