Changeset 32729

Show
Ignore:
Timestamp:
31.01.2019 16:38:12 (3 months ago)
Author:
ak19
Message:

Part of Ticket #947 the Lucene Index File Locking Fix. Lucene search had broken for GS2, thanks to Pascal Angst for identifying this. The fix committed at that time was incomplete as it had not been applied for GS2, because GS2 went through GS2LuceneQuery's main() method. GS2LuceneQuery still managed to compile after the fix with no syntax errors, because the superclass' initialise() method ended up getting called from main(), instead of the new GS2LuceneQuery.initialise(IndexReader?) variant. Now the GS2LuceneQuery.main() method used by GS2 behaves like the GS2LuceneSearch class used by GS3: first instantiating an IndexReader? object then passing this to the GS2LuceneQuery object's initialise(IndexReader?) method. Lucene searching should work again in GS2, will test.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/common-src/indexers/lucene-gs/src/org/greenstone/LuceneWrapper4/GS2LuceneQuery.java

    r32641 r32729  
    592592    static protected boolean query_result_caching_enabled = false; 
    593593 
    594  
     594    /** 
     595     * This main() method is used by GS2 to do searches. 
     596     * In GS2, lucene_query.pl calles this main() method in the LuceneWrapper4.jar. This main method instantiates both 
     597     * a GS2LuceneQuery and an IndexReader object. It then passes the reader to the GS2LuceneQuery object by calling 
     598     * the GS2LuceneQuery.initialise(reader) method. This main() method then finally performs the search with the provided query. 
     599     * GS3 doesn't use this main() method. Instead a GS2LuceneSearch object (of gsdl3.jar) instantiates both 
     600     * the GS2LuceneQuery and IndexReader objects and proceeds the same way. 
     601     */ 
    595602    static public void main (String args[]) 
    596603    { 
     
    660667        } 
    661668         
    662         if (!queryer.initialise()) { 
    663             queryer.cleanUp(); // will close reader object IF reader was instantiated 
     669        Directory full_indexdir_dir = FSDirectory.open(new File(index_directory)); 
     670        IndexReader reader = DirectoryReader.open(full_indexdir_dir); // Returns a IndexReader reading the index in the given Directory. 
     671                        // Now readOnly=true by default, and therefore also for searcher created in initialise() call below. 
     672        if (!queryer.initialise(reader)) { 
     673        if(reader != null) reader.close(); // close reader object IF reader was instantiated 
     674        queryer.cleanUp(); // will close searcher object if non-null 
    664675        return; 
    665676        } 
     
    684695        } 
    685696        } 
    686         queryer.cleanUp(); 
     697        if(reader != null) reader.close(); 
     698        queryer.cleanUp(); 
    687699    } 
    688700    catch (IOException exception) {