You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by to...@axelspringer.de on 2011/08/16 09:56:51 UTC
Filtering results based on a set of values for a field
Hello, Solrs
we are trying to filter out documents written by (one or more of) the authors from
a mediumish list (~2K). The document set itself is in the millions.
Apart from the obvious approach of building a huge OR-list and appending it
to the query, it seems that writing a Lucene[1] filter (or a SolrFilter[2]) seems
to suggest itself. In fact [3] seems to strongly encourage this approach.
Basically, as we understand it, the filter's method getDocIdSet gets called and is
fed with index segments, "one spoonful at a time". It then decides which docs
of the segment will be accepted, setting the corresponding bits in the result (in
our case, e.g. look up the document's author's name in a HashMap or something
like it).
Our first question is: how does it all fit together? Would be enough to write such a
class? How do I reference that in the SOLR configuration? In the query? A Lucene
Filter or a SolrFilter?
The problem is, we are experiencing very slow response times, in the order of
12 seconds for a query (the OR alternative, which we tested on a smallish author
list of aboug a couple of hundred is nearly-instantaneous).
Our second question is: are we on track with this? Intuition would say, of course,
that sifting sequentially through the index, checking each document for its author
*will* take its time. So may be the approach is doomed? Are there other, better
approaches?
Thanks for any pointers
------
[1] <https://builds.apache.org/job/Lucene-3.x/javadoc/all/org/apache/lucene/search/Filter.html?is-external=true>
[2] <http://lucene.apache.org/solr/api/org/apache/solr/search/SolrFilter.html>
[1] <http://wiki.apache.org/lucene-java/FilteringOptions>
-- tomás
Re: Filtering results based on a set of values for a field
Posted by Erick Erickson <er...@gmail.com>.
Good luck, and let us know what the results are. About dropping the cache.. That
shouldn't be a problem, it should just be computed when your
component is called
the first time, so starting the server (or opening a new searcher)
should re-compute
it. Your filters shouldn't be very big, just maxDocs/8 bytes long...
By the way, there exist "user caches" (see solrconfig.xml) that you can use
for whatever you want, so you could consider stashing your filters in there. The
neat thing is that they get notified whenever the searcher is opened (?) and you
can regenerate the data held there. MIght be more convenient than mucking with
filter query caching...
Best
Erick
On Fri, Aug 19, 2011 at 2:58 AM, Tomas Zerolo
<to...@axelspringer.de> wrote:
> On Thu, Aug 18, 2011 at 02:32:48PM -0400, Erick Erickson wrote:
>> Hmmm, I'm still not getting it...
>>
>> You have one or more lists. These lists change once a month or so. Are
>> you trying
>> to include or exclude the documents in these lists?
>
> In our specific case to include *only* the documents having a value of
> an attribute ("author") in this list (the user decides at query time
> which of those lists to use). But we do expect the problem to become
> more general over time...
>
>> And do the authors you want
>> to include or exclude change on a per-query basis or would you be all set if you
>> just had a filter that applied to all the authors on a particular list?
>
> No. ATM there are two "fixed" lists (in the sense that they are updated
> like "monthly". One problem: the document basis itself is huge (in the
> abouts of 3.5 million). Re-indexing is a painful exercise taking days,
> so we tend not to do it too often ;-)
>
>> But I *think* what you want is a SearchComponent that implements your
>> Filter. You can see various examples of how to add components to a seach
>> handler in the solrconfig.xml file.
>
> Thanks a lot for the pointer. Rushing to read on it.
>
>> WARNING: Haven't done this myself, so I'm partly guessing here.
>
> Hey: I asked for pointers and you're giving me some, so I'm a happy
> man now :-)
>
>> Although here's a hint that someone else has used this approach:
>> http://www.mail-archive.com/solr-user@lucene.apache.org/msg54240.html
>
> Thanks again
>
>> And you'll want to insure that the Filter is cached so you don't have to compute
>> it more than once.
>
> Yes, I hope that will be the trick giving us the needed boost. Somehow
> we'll have to figure out how to drop the cache when a new version of the
> list arrives (without killing everyone in the building).
>
> I'll sure report back.
>
> Regards
> -- tomás
>
Re: Filtering results based on a set of values for a field
Posted by Tomas Zerolo <to...@axelspringer.de>.
On Thu, Aug 18, 2011 at 02:32:48PM -0400, Erick Erickson wrote:
> Hmmm, I'm still not getting it...
>
> You have one or more lists. These lists change once a month or so. Are
> you trying
> to include or exclude the documents in these lists?
In our specific case to include *only* the documents having a value of
an attribute ("author") in this list (the user decides at query time
which of those lists to use). But we do expect the problem to become
more general over time...
> And do the authors you want
> to include or exclude change on a per-query basis or would you be all set if you
> just had a filter that applied to all the authors on a particular list?
No. ATM there are two "fixed" lists (in the sense that they are updated
like "monthly". One problem: the document basis itself is huge (in the
abouts of 3.5 million). Re-indexing is a painful exercise taking days,
so we tend not to do it too often ;-)
> But I *think* what you want is a SearchComponent that implements your
> Filter. You can see various examples of how to add components to a seach
> handler in the solrconfig.xml file.
Thanks a lot for the pointer. Rushing to read on it.
> WARNING: Haven't done this myself, so I'm partly guessing here.
Hey: I asked for pointers and you're giving me some, so I'm a happy
man now :-)
> Although here's a hint that someone else has used this approach:
> http://www.mail-archive.com/solr-user@lucene.apache.org/msg54240.html
Thanks again
> And you'll want to insure that the Filter is cached so you don't have to compute
> it more than once.
Yes, I hope that will be the trick giving us the needed boost. Somehow
we'll have to figure out how to drop the cache when a new version of the
list arrives (without killing everyone in the building).
I'll sure report back.
Regards
-- tomás
Re: Filtering results based on a set of values for a field
Posted by Erick Erickson <er...@gmail.com>.
Hmmm, I'm still not getting it...
You have one or more lists. These lists change once a month or so. Are
you trying
to include or exclude the documents in these lists? And do the authors you want
to include or exclude change on a per-query basis or would you be all set if you
just had a filter that applied to all the authors on a particular list?
But I *think* what you want is a SearchComponent that implements your
Filter. You can see various examples of how to add components to a seach
handler in the solrconfig.xml file.
WARNING: Haven't done this myself, so I'm partly guessing here.
Although here's a hint that someone else has used this approach:
http://www.mail-archive.com/solr-user@lucene.apache.org/msg54240.html
And you'll want to insure that the Filter is cached so you don't have to compute
it more than once.
Best
Erick
On Thu, Aug 18, 2011 at 8:59 AM, Tomas Zerolo
<to...@axelspringer.de> wrote:
> On Thu, Aug 18, 2011 at 08:36:08AM -0400, Erick Erickson wrote:
>> How does this list of authors get selected? The reason I'm asking is
>> I'm wondering
>> if you can "define the problem away". In other words, I'm wondering if this
>> is an XY problem (http://people.apache.org/~hossman/#xyproblem).
>
> :-)
>
>> I can't imagine you expect a user to specify up to 2k authors...
>
> Of course not for each individual query.
>
>> so there must
>> be something programmatic going on here, perhaps you can index some clever
>> information with the docs that'll make this more tractable...
>
> Alas, they do provide a list of names on a regular basis -- which comes from
> an external source (which changes slowly and is provided, e.g. once a month).
>
> To be more precise there will be a couple of those lists.
>
> I don't see (yet) how to define the problem away, but I keep trying...
>
> Thanks for the nudge
> -- tomás
>
Re: Filtering results based on a set of values for a field
Posted by Tomas Zerolo <to...@axelspringer.de>.
On Thu, Aug 18, 2011 at 08:36:08AM -0400, Erick Erickson wrote:
> How does this list of authors get selected? The reason I'm asking is
> I'm wondering
> if you can "define the problem away". In other words, I'm wondering if this
> is an XY problem (http://people.apache.org/~hossman/#xyproblem).
:-)
> I can't imagine you expect a user to specify up to 2k authors...
Of course not for each individual query.
> so there must
> be something programmatic going on here, perhaps you can index some clever
> information with the docs that'll make this more tractable...
Alas, they do provide a list of names on a regular basis -- which comes from
an external source (which changes slowly and is provided, e.g. once a month).
To be more precise there will be a couple of those lists.
I don't see (yet) how to define the problem away, but I keep trying...
Thanks for the nudge
-- tomás
Re: Filtering results based on a set of values for a field
Posted by Erick Erickson <er...@gmail.com>.
How does this list of authors get selected? The reason I'm asking is
I'm wondering
if you can "define the problem away". In other words, I'm wondering if this
is an XY problem (http://people.apache.org/~hossman/#xyproblem).
I can't imagine you expect a user to specify up to 2k authors, so there must
be something programmatic going on here, perhaps you can index some clever
information with the docs that'll make this more tractable...
Best
Erick
On Wed, Aug 17, 2011 at 9:56 AM, Tomas Zerolo
<to...@axelspringer.de> wrote:
> On Tue, Aug 16, 2011 at 07:56:51AM +0000, tomas.zerolo@axelspringer.de wrote:
>> Hello, Solrs
>>
>> we are trying to filter out documents written by (one or more of) the authors from
>> a mediumish list (~2K). The document set itself is in the millions.
>
> [...]
>
> Sorry. Forgot to say that we are using SOLR 1.4 (yet). But any pointers, even if
> they are 3.x only are highly appreciated.
>
> Regards
> -- tomás
>
Re: Filtering results based on a set of values for a field
Posted by Tomas Zerolo <to...@axelspringer.de>.
On Tue, Aug 16, 2011 at 07:56:51AM +0000, tomas.zerolo@axelspringer.de wrote:
> Hello, Solrs
>
> we are trying to filter out documents written by (one or more of) the authors from
> a mediumish list (~2K). The document set itself is in the millions.
[...]
Sorry. Forgot to say that we are using SOLR 1.4 (yet). But any pointers, even if
they are 3.x only are highly appreciated.
Regards
-- tomás