Batch delete for items older than an expiration date.

284 views
Skip to first unread message

Miguel Ludert

unread,
May 4, 2012, 12:56:44 PM5/4/12
to rav...@googlegroups.com
I'm still working to get the hang of Lucene and am not sure how to structure this query.

I'm trying to delete all items older than a certain date.  It seems I have to do a range query, yes?  What format do I use for the dates?

            _Session.Advanced.DatabaseCommands.DeleteByIndex(
                typeof(AssetsByExpirationDate).Name,
                new IndexQuery()
                {
                    Query = string.Format("ExpirationDate:[\"{0:MM/dd/yyyy}\" TO \"{1:MM/dd/yyyy}\"]", DateTime.MinValue, new DateTime(2012,6,1))
                });

Any guidance on this topic would be appreciated.

Oren Eini (Ayende Rahien)

unread,
May 5, 2012, 7:31:46 AM5/5/12
to rav...@googlegroups.com
See:

The current format is yyyyMMddhhmmsszzzzz (or something like that, this is from memory).
Please use the session.Query() or session.Advanced.LuceneQuery() to create the query, it is much easier and would avoid issues if we change the date format (which we did for 1.2)

Miguel Ludert

unread,
May 5, 2012, 6:48:41 PM5/5/12
to rav...@googlegroups.com
Thanks, The Advanced.LuceneQuery did the trick.


On Saturday, May 5, 2012 7:31:46 AM UTC-4, Oren Eini wrote:
See:

The current format is yyyyMMddhhmmsszzzzz (or something like that, this is from memory).
Please use the session.Query() or session.Advanced.LuceneQuery() to create the query, it is much easier and would avoid issues if we change the date format (which we did for 1.2)
Reply all
Reply to author
Forward
0 new messages