In the search use case in my application, I don't need to score query results 
since all results are equal. Also query patterns are also more or less fixed.

Given these conditions, I am trying to increase search performance by

1.     Using ConstantScoreQuery so that scoring overhead is removed since 
scoring is not required in my search use case. I also use a custom Sort object 
which does not sort by score (see code below).

Is this enough to remove scoring overhead in search?

2.     Using query cache

My understanding is that query cache would cache query results and hence lead 
to significant increase in performance. Is this understanding correct?

I am using Lucene version 5.4.1 where query cache seems to be enabled by 
default (, but I am not able 
to see any significant change in search performance.

Here is the code I am testing with:

DirectoryReader reader =;      //using 

IndexSearcher searcher = new IndexSearcher(reader);            //IndexReader 
and IndexSearcher are created only once


//search code

QueryParser parser = new QueryParser("fieldname", analyzer);

Query query = new ConstantScoreQuery(parser.parse("text"));

ScoreDoc[] hits =, 20, sort).scoreDocs;

Given above conditions in my application, is there anything more I can do to 
get better search performance?

Reply via email to