Hello,

I've been wrestling with a query use case, perhaps someone has done this
already?
Is it possible to write a query that excludes results based on another
query?

Scenario:
I have an index that holds:
   'customer'  (textgen)
   'product'   (textgen)
   'saledate'   (date)

I'm looking to return documents for 'customer' entries who have bought a
'product' in the past, but haven't bought in, say, the last month.
(i.e. need to exclude *all* 'customer' documents who have bought 'product'
in the last month, as well as those who have never bought 'product')

A very simple query like this:
     q=products:Dog AND -(products:Dog AND saledate:[2011-01-01T00:00:00Z TO
*])
returns 'Dog' documents prior to 1 Jan, but these need to be excluded if
there are matches after 1 Jan.
I wasn't expecting the above query to do the extra exclusion - it's just to
illustrate the general problem that it operates at document level, not query
level (like a SQL subquery).
If I could could pipe the results of the above to another query, that would
likely do the trick.
I've tried negative boosts, magic _query_, query() and such, but with no
luck.

Is this possible?
Any insight into how to write such a query would be much appreciated!

Thanks,
Peter

Reply via email to