Ignore:
Timestamp:
2011-10-07T11:36:07+13:00 (13 years ago)
Author:
sjm84
Message:

Lucene 3.x version of code accidentally commited rolling back to 2.x compatible version

File:
1 edited

Legend:

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

    r24725 r24731  
    4545import org.apache.lucene.index.Term;
    4646import org.apache.lucene.analysis.Analyzer;
    47 
    48 import org.apache.lucene.store.SimpleFSDirectory;
    49 import org.apache.lucene.index.IndexWriter.MaxFieldLength;
    5047
    5148import java.util.Stack;
     
    193190    protected String file_id_ = null;
    194191
     192    static private String[] stop_words = GS2Analyzer.STOP_WORDS;
     193
     194
    195195    /** pass in true if want to create a new index, false if want to use the existing one */
    196196    public Indexer (String doc_tag_level, File index_dir, boolean create)
     
    206206        reader.setFeature("http://xml.org/sax/features/validation", false);
    207207
    208         SimpleFSDirectory index_dir_dir = new SimpleFSDirectory(new File(index_dir.getPath()));
    209 
    210         analyzer_ = new GS2Analyzer(); // uses build in stop_word_set
    211 
    212         writer_ = new IndexWriter(index_dir_dir, analyzer_, create, MaxFieldLength.UNLIMITED);
    213                        
     208        analyzer_ = new GS2Analyzer(stop_words);
     209
     210        writer_ = new IndexWriter(index_dir.getPath(), analyzer_, create);
    214211        // by default, will only index 10,000 words per document
    215212        // Can throw out_of_memory errors
     
    321318        //String node_id = atts.getValue("gs2:id");
    322319        //print(" " + qName + ": " + node_id + " (" + mode_ + ")" );
    323         //current_doc_.add(new Field("nodeID", node_id, Field.Store.YES, Field.Index.NOT_ANALYZED));
     320        //current_doc_.add(new Field("nodeID", node_id, Field.Store.YES, Field.Index.UN_TOKENIZED));
    324321       
    325322        current_doc_oid_ = atts.getValue("gs2:docOID");
    326323        print(" " + qName + ": " + current_doc_oid_ + " (" + mode_ + ")" );
    327         current_doc_.add(new Field("docOID", current_doc_oid_, Field.Store.YES, Field.Index.NOT_ANALYZED));
     324        current_doc_.add(new Field("docOID", current_doc_oid_, Field.Store.YES, Field.Index.UN_TOKENIZED));
    328325        }
    329326       
     
    362359        if (qName.equals(indexable_current_node_))
    363360            {
    364             current_doc_.add(new Field(qName, current_contents_, Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.YES));
     361            current_doc_.add(new Field(qName, current_contents_, Field.Store.NO, Field.Index.TOKENIZED, Field.TermVector.YES));
    365362            // The byXX fields are used for sorting search results
    366363            // We don't want to do that for Text or AllFields fields
     
    368365            if (!qName.equals("TX") && !qName.equals("ZZ"))
    369366                {
    370                 current_doc_.add(new Field("by" + qName, current_contents_, Field.Store.NO, Field.Index.NOT_ANALYZED, Field.TermVector.NO));
     367                current_doc_.add(new Field("by" + qName, current_contents_, Field.Store.NO, Field.Index.UN_TOKENIZED, Field.TermVector.NO));
    371368                }
    372369           
     
    475472    {
    476473        debug("GS2LuceneDelete.deleteDocument(" + doc_id + ")");
    477         debug("- Initial number of documents in index: " + writer_.numDocs());
     474        debug("- Initial number of documents in index: " + writer_.docCount());
    478475        writer_.deleteDocuments(new Term("docOID", doc_id));
    479         debug("- Final number of documents in index: " + writer_.numDocs());
     476        debug("- Final number of documents in index: " + writer_.docCount());
    480477    }
    481478
Note: See TracChangeset for help on using the changeset viewer.