luceneインデックスの追加とクエリー

1137 ワード

public class IndexFiles { 
  //    :: IndexFiles [      ] [       ] ... 
  public static void main(String[] args) throws Exception {
    String indexPath = args[0];
    IndexWriter writer;
    //                   ( 3            )
    writer = new IndexWriter(indexPath, new SimpleAnalyzer(), false);

    for (int i=1; i
public class Search { 
  public static void main(String[] args) throws Exception {
    String indexPath = args[0], queryString = args[1];
    //          
    Searcher searcher = new IndexSearcher(indexPath);
    //     :             
    Query query = QueryParser.parse(queryString, "body", 
                              new SimpleAnalyzer());
    //      Hits  
    Hits hits = searcher.search(query);
    //  hits                   
    for (int i=0; i