lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Atul Bisaria <atul.bisa...@ericsson.com>
Subject Increase search performance
Date Tue, 30 Jan 2018 13:45:31 GMT
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 (https://issues.apache.org/jira/browse/LUCENE-6784),
but I am not able to see any significant change in search performance.



Here is the code I am testing with:



DirectoryReader reader = DirectoryReader.open(directory);      //using MMapDirectory

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

searcher.setQueryCachingPolicy(QueryCachingPolicy.ALWAYS_CACHE);



//search code

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

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



ScoreDoc[] hits = searcher.search(query, 20, sort).scoreDocs;





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








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