query syntax for complement set

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

query syntax for complement set

Doug Daniels
Hi,

I'm trying to find a way to express a certain query and wondering if
anyone could help.

The query is against a schema that stores the user_ids who have worked
on each document in a multi-value integer field called 'user_ids'.  I'd
like to query solr for all documents that anyone other than a few users
have worked on.

For instance, say the user group I'm working with is user_ids 1, 3, and
6.  I'd like to get back the documents that any other users have worked
on--the complement set of users.  This would be too many users to list
out individually, I imagine.

This would be easier if I were trying to simply exclude documents that
users 1,3, and 6 had worked on, but I'm really looking to "include"
documents that this complement set of users worked on.

Wondering if there's any way to write this query without listing out
each of the IDs in the complement set individually or (slightly better)
creating range queries to express the complement set.

Thanks,
Doug
Reply | Threaded
Open this post in threaded view
|

Re: query syntax for complement set

hossman

: The query is against a schema that stores the user_ids who have worked on each
: document in a multi-value integer field called 'user_ids'.  I'd like to query
: solr for all documents that anyone other than a few users have worked on.
:
: For instance, say the user group I'm working with is user_ids 1, 3, and 6.
: I'd like to get back the documents that any other users have worked on--the
: complement set of users.  This would be too many users to list out
: individually, I imagine.

if i'm understanding correctly you want documents where a multivalued
field contains at least one value which is not in your input set (even if
it also contains some items which are in your input set), is that correct?

I can't think of anyway to do that off the top of my head ... hmmm...  no
that's a touch one.  set operations in Solr (and when matching in
lucene) are really all about the documents themselves ... there's really
no easy way to operate on the set of values for a field for a doc.

you could probably acheive something like this with a custom FunctionQuery
(you can do almost anything with a FunctionQuery) -- but you'd have to
write a custom ValueSource that knows about multiple values first.



-Hoss