You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@lucene.apache.org by entdeveloper <ca...@gmail.com> on 2011/01/07 01:57:39 UTC

CachingWrapperFilter use

How is the CachingWrapperFilter intended to be used in a web environment
where new requests come in to be executed? Each time a search comes in, I
create a filter and then wrap it with a new instance of the
CachingWrapperFilter (to cache searches when requests for the same input
comes in) like so:

TopDocs search(String input) {
  Term term = new Term("name", input);
  Filter filter = new CachingWrapperFilter(new PrefixFilter(term));

  return indexSearcher.search(new MatchAllDocsQuery(), filter, 10, null);
}

So if my understanding is correct, given the javadoc and example in 'Lucene
in Action', this won't actually cache anything because each time a new
request comes in, a new instance of CachingWrapperFilter is being used. I'm
a little confused as to how CachingWrapperFilter is to be used otherwise.
Can anyone help?
-- 
View this message in context: http://lucene.472066.n3.nabble.com/CachingWrapperFilter-use-tp2209175p2209175.html
Sent from the Lucene - General mailing list archive at Nabble.com.

Re: CachingWrapperFilter use

Posted by entdeveloper <ca...@gmail.com>.
Ok thanks! wow, took me a while to wrap my head around that for some reason.

so my followup question is: does lucene offer something comparable to solr's
FilterCache out of the box, to cache multiple filters' result sets?


Uwe Schindler wrote:
> 
> That's exactly how its intended to work!
> 
> Uwe
> 
> --
> Uwe Schindler
> H.-H.-Meier-Allee 63, 28213 Bremen
> http://www.thetaphi.de
> 
> 

-- 
View this message in context: http://lucene.472066.n3.nabble.com/CachingWrapperFilter-use-tp2209175p2229401.html
Sent from the Lucene - General mailing list archive at Nabble.com.

Re: CachingWrapperFilter use

Posted by Uwe Schindler <uw...@thetaphi.de>.
That's exactly how its intended to work!

Uwe



"entdeveloper" <ca...@gmail.com> schrieb:

>
>Oook. So I think I figured this out: the CachingWrapperFilter isn't
>really
>intended to be used dynamically (i.e. the wrapped filter changes for
>each
>search). It's only really useful if the same filter is being used every
>time
>(e.g. filter type=movies for a movie search site).
>
>Am I getting that right?
>
>I guess what I need is something like Solr's filter cache, where
>filters
>based on repeated search criteria are retrieved from the cache. Has
>anyone
>written something like this and used filters in this way before?
>
>I have a search where one of the criteria is a location (New York, Los
>Angeles, Chicago). I want to put this term in a filter, so that every
>subsequent request for one of those locations is pulled from a cache
>for
>better performance.
>
>
>entdeveloper wrote:
>> 
>> How is the CachingWrapperFilter intended to be used in a web
>environment
>> where new requests come in to be executed? Each time a search comes
>in, I
>> create a filter and then wrap it with a new instance of the
>> CachingWrapperFilter (to cache searches when requests for the same
>input
>> comes in) like so:
>> 
>> TopDocs search(String input) {
>>   Term term = new Term("name", input);
>>   Filter filter = new CachingWrapperFilter(new PrefixFilter(term));
>> 
>>   return indexSearcher.search(new MatchAllDocsQuery(), filter, 10,
>null);
>> }
>> 
>> So if my understanding is correct, given the javadoc and example in
>> 'Lucene in Action', this won't actually cache anything because each
>time a
>> new request comes in, a new instance of CachingWrapperFilter is being
>> used. I'm a little confused as to how CachingWrapperFilter is to be
>used
>> otherwise. Can anyone help?
>> 
>
>-- 
>View this message in context:
>http://lucene.472066.n3.nabble.com/CachingWrapperFilter-use-tp2209175p2215038.html
>Sent from the Lucene - General mailing list archive at Nabble.com.

--
Uwe Schindler
H.-H.-Meier-Allee 63, 28213 Bremen
http://www.thetaphi.de

Re: CachingWrapperFilter use

Posted by entdeveloper <ca...@gmail.com>.
Oook. So I think I figured this out: the CachingWrapperFilter isn't really
intended to be used dynamically (i.e. the wrapped filter changes for each
search). It's only really useful if the same filter is being used every time
(e.g. filter type=movies for a movie search site).

Am I getting that right?

I guess what I need is something like Solr's filter cache, where filters
based on repeated search criteria are retrieved from the cache. Has anyone
written something like this and used filters in this way before?

I have a search where one of the criteria is a location (New York, Los
Angeles, Chicago). I want to put this term in a filter, so that every
subsequent request for one of those locations is pulled from a cache for
better performance.


entdeveloper wrote:
> 
> How is the CachingWrapperFilter intended to be used in a web environment
> where new requests come in to be executed? Each time a search comes in, I
> create a filter and then wrap it with a new instance of the
> CachingWrapperFilter (to cache searches when requests for the same input
> comes in) like so:
> 
> TopDocs search(String input) {
>   Term term = new Term("name", input);
>   Filter filter = new CachingWrapperFilter(new PrefixFilter(term));
> 
>   return indexSearcher.search(new MatchAllDocsQuery(), filter, 10, null);
> }
> 
> So if my understanding is correct, given the javadoc and example in
> 'Lucene in Action', this won't actually cache anything because each time a
> new request comes in, a new instance of CachingWrapperFilter is being
> used. I'm a little confused as to how CachingWrapperFilter is to be used
> otherwise. Can anyone help?
> 

-- 
View this message in context: http://lucene.472066.n3.nabble.com/CachingWrapperFilter-use-tp2209175p2215038.html
Sent from the Lucene - General mailing list archive at Nabble.com.