lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Harini Raghavan <>
Subject Re: Lucene search is very slow
Date Thu, 20 Oct 2005 10:15:10 GMT
Hi Chris,
I am initializing IndexSearcher every time the  search is executed.  The 
below is the search related code that is in a singleton class:
public Hits searchDocuments(DocumentSearchCriteria searchCriteria, List 
companies) throws ApplicationException {
        Hits hits = null;
        String indexLoc = luceneConfig.getIndexDir();
        Directory fsDir = getIndexDirectory(indexLoc, false);
        IndexSearcher searcher = null;
        try {
             searcher = new IndexSearcher(dir);
        } catch(IOException ex) {
            logger.error("Exception occurred while getting the 
            throw new ApplicationException(ex);

        Query query = indexSearchUtil.getSearchQuery(searchCriteria, 

        SortField dateField = new 
SortField(IndexSearchConstants.DATE_FOR_SORTING, true);
        SortField companyNameField = new 
SortField(IndexSearchConstants.COMPANY_NAME_FOR_SORTING, false);
        SortField titleField = new 
SortField(IndexSearchConstants.TITLE_FOR_SORTING, false);

        SortField[] sortFields = {dateField, companyNameField, titleField};
        try {
            hits =, new Sort(sortFields));
  "Found " + hits.length() + " document(s) that 
matched query '" + query + "':");
        } catch(Exception e) {
            logger.error("Exception occurred in searchDocuments()", e);
            throw new ApplicationException(e);
        return hits;

I do not close the IndexSearcher anywhere. Do you think I should not 
create a new instance of IndexSearcher every time? Also, the index gets 
updated every day with the latest document. So will the IndexSearcher 
get the latest documents if I do not initialize it every time the search 
is executed?


Chris Lu wrote:

>Did you close the IndexReader every time your search is finished?
>If so, 10G data will take a long time to warm up the IndexReader.
>Full-Text Search on Any Databases
>On 10/10/05, Koji Sekiguchi <> wrote:
>>Is it really the part of Lucene slow?
>>Please take thread dumps every 15 secs, 3 to 4 times.
>>What can you look at them?
>>>-----Original Message-----
>>>From: Harini Raghavan []
>>>Sent: Tuesday, October 11, 2005 12:38 AM
>>>Subject: Lucene search is very slow
>>>I am using lucene for search functionality in my j2ee application using
>>>JBoss as app server. The lucene index directory size is almsot 10G. The
>>>performance has been quite good until now. But after the last deploy,
>>>when the server was restarted , the lucene search has become very slow.
>>>It takes almost 3-4 mins for simple searches on the index. There has
>>>been no changes to the application in the new build.
>>>Does anyone have an idea what could be wrong?
>>>To unsubscribe, e-mail:
>>>For additional commands, e-mail:
>>To unsubscribe, e-mail:
>>For additional commands, e-mail:
>To unsubscribe, e-mail:
>For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message