Changeset 25763

Show
Ignore:
Timestamp:
06.06.2012 14:30:26 (7 years ago)
Author:
sjm84
Message:

Fixed some deprecated stuff in LuceneSearch?

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/LuceneSearch.java

    r25762 r25763  
    22 
    33// Greenstone classes 
    4 import org.greenstone.gsdl3.util.*; 
    5  
    6 // XML classes 
    7 import org.w3c.dom.Element; 
    8 import org.w3c.dom.Document; 
    9 import org.w3c.dom.NodeList; 
    10  
     4import java.io.File; 
     5import java.io.Serializable; 
     6import java.util.ArrayList; 
    117import java.util.HashMap; 
    12 import java.util.ArrayList; 
    13  
    14 import org.apache.lucene.analysis.Analyzer; 
    15 import org.apache.lucene.analysis.standard.StandardAnalyzer; 
    16 import org.apache.lucene.document.*; //Document; 
    17 import org.apache.lucene.search.Searcher; 
     8 
     9import org.apache.log4j.Logger; 
     10import org.apache.lucene.index.IndexReader; 
     11import org.apache.lucene.index.Term; 
    1812import org.apache.lucene.search.IndexSearcher; 
    19 import org.apache.lucene.index.IndexReader; 
    2013import org.apache.lucene.search.Query; 
    21 import org.apache.lucene.queryParser.QueryParser; 
    22 //import org.apache.lucene.search.Hits; 
    2314import org.apache.lucene.search.TermQuery; 
    2415import org.apache.lucene.search.TopDocs; 
    25 import org.apache.lucene.index.Term; 
     16import org.apache.lucene.store.Directory; 
    2617import org.apache.lucene.store.FSDirectory; 
    27 import org.apache.lucene.store.Directory; 
    28  
    29 import org.greenstone.LuceneWrapper3.GS2Analyzer; 
    30 import java.io.File; 
    31 import java.io.Serializable; 
    32  
    33 import org.apache.log4j.*; 
    34  
    35 /** 
    36  * 
    37  */ 
     18import org.greenstone.gsdl3.util.GSFile; 
     19import org.greenstone.gsdl3.util.GSXML; 
     20import org.w3c.dom.Element; 
     21import org.w3c.dom.NodeList; 
    3822 
    3923public class LuceneSearch extends AbstractTextSearch 
    4024{ 
    41  
    4225    static Logger logger = Logger.getLogger(org.greenstone.gsdl3.service.LuceneSearch.class.getName()); 
    4326 
     
    11598    protected void initResultElement(Element result, Element doc_node_list, Element metadata_list) 
    11699    { 
    117  
    118100        // Create a new (empty) result message 
    119101        result.setAttribute(GSXML.FROM_ATT, QUERY_SERVICE); 
     
    139121    protected boolean hasQueryString(Element param_list, Element metadata_list) 
    140122    { 
    141  
    142123        // Process the request parameters to make sure a query has been specified 
    143124        HashMap<String, Serializable> params = GSXML.extractParams(param_list, false); 
     
    157138    protected Element processTextQuery(Element request) 
    158139    { 
    159  
    160140        Element result = this.doc.createElement(GSXML.RESPONSE_ELEM); 
    161141        Element doc_node_list = this.doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER); 
     
    189169            index_dir += File.separator + index; 
    190170            Directory index_dir_dir = FSDirectory.open(new File(index_dir)); 
    191             Searcher searcher = new IndexSearcher(index_dir_dir); 
    192             Analyzer analyzer = new GS2Analyzer(); 
     171            IndexSearcher searcher = new IndexSearcher(index_dir_dir); 
    193172 
    194173            Term term = new Term("content", query_string); 
     
    200179            GSXML.addMetadata(this.doc, metadata_list, "numDocsMatched", "" + hits.scoreDocs.length); 
    201180 
    202             IndexReader reader = ((IndexSearcher) searcher).getIndexReader(); 
     181            IndexReader reader = searcher.getIndexReader(); 
    203182 
    204183            for (int i = 0; i < hits.scoreDocs.length; i++) 
     
    219198        return result; 
    220199    } 
    221  
    222200}