lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anton Lyska <profondome...@gmail.com>
Subject CachingWrapperQuery performance
Date Mon, 15 Jun 2015 08:56:51 GMT
 Hi,

    I have performance issues with CachingWrapperQuery with lucene 5.2 and
dont know how to solve it.

Prehistory:
    I have search with different parameters, where some parameters are used
more frequently then others. For these params I used filters(and cached
them), and my search looked like this

    BooleanFilter bf = new BooleanFilter ();
    bf.add(.., BooleanClause.Occur.MUST);    //frequently used params here
    bf.add(.., BooleanClause.Occur.MUST);

    Filter searchFilter = new CachingWrapperFilter(bf);    //and this
filter object was reused between queries

    BooleanQuery searchQuery = new BooleanQuery();
    searchQuery.add(.., BooleanClause.Occur.MUST);
    searchQuery.add(.., BooleanClause.Occur.MUST);

    hits = searcher.search(searchQuery, searchFilter, count, sort);

And everything were great. I looked at two popular queries and each took 32
ms and 22 ms to execute.

Now I did upgrade Lucene to 5.2 (from 5.0), and saw that filters are
deprecated and its advisable to use queries and CachingWrapperQuery.

So i changed sources to this:


    BooleanQuery bq = new BooleanQuery ();   //now it becomes BooleanQuery
    bq.add(.., BooleanClause.Occur.MUST);    //frequently used params here,
same terms as before
    bq.add(.., BooleanClause.Occur.MUST);

    Query cachedQuery = new CachingWrapperQuery(bq);    //this object is
reused between queries

    BooleanQuery searchQuery = new BooleanQuery();
    searchQuery.add(.., BooleanClause.Occur.MUST);
    searchQuery.add(.., BooleanClause.Occur.MUST);
    searchQuery.add(cachedQuery, BooleanClause.Occur.FILTER);    //here i
add cached part of the query

    hits = searcher.search(searchQuery, count, sort);

Later I looked at same queries, and they took 145ms and 95ms  to execute!

Moving to CachingWrapperQuery was the only difference between queries, so
question is:
   How to use CachingWrapperQuery right in my situation, or should I switch
back to filters?

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message