Okay, here's my SearchQuerySet query, which should exclude all old or far-future events from our search results:
sqs = sqs.exclude(
SQ(contenttype='events.event') &
(
SQ(date__lte=(today - SITE_SEARCH_EVENTS_FROM)) |
SQ(date__gte=(today + SITE_SEARCH_EVENTS_TO))
)
)
Here is the SQ.__repr__() it generates (the sites part is applied to the query earlier on):
<SQ: AND (content__exact=old AND content__exact=97 AND sites__in=1 AND NOT ((contenttype__exact=events.event AND (date__lte=2010-01-15 OR date__gte=2010-04-22))))>
Here is the xapian.Query.get_description() that the SQ produces:
Xapian::Query(((Zold OR old) AND (Z97 OR 97) AND (ZXSITES1 OR XSITES1) AND (ZXCONTENTTYPEevents.ev OR XCONTENTTYPEevents.event) AND (VALUE_RANGE 15 00010101000000 20100115000000 OR VALUE_RANGE 15 20100422000000 99990101000000)))
Because of the 3rd AND, this filters by my exclusion instead of excluding it. It should be AND_NOT (ZXCONTENTTYPE...
If I could only change that one AND to an AND_NOT, my problems would be over for now. I've been unable to do it with my own experimentation, however.
Thank you again for any help you can provide!