Examples of IndexReader


Examples of org.apache.lucene.index.IndexReader

    if (!oDir.exists()) {
      FileSystem oFS = new FileSystem();
      try { oFS.mkdirs(sDirectory); } catch (Exception e) { throw new IOException(e.getClass().getName()+" "+e.getMessage()); }
    } // fi

    IndexReader oReader = IndexReader.open(sDirectory);

    int iDeleted = oReader.deleteDocuments(new Term("guid", sGuid));

    oReader.close();

    return iDeleted;
  } // delete
View Full Code Here

Examples of org.apache.lucene.index.IndexReader

    addDoc("2", new String[]{ "aa","bb"}, new String[]{"aaa","bbb"}, new int[]{200,200});
    addDoc("3", new String[]{ "aa","bb"}, new String[]{"bbb","aaa"}, new int[]{300,300});
    addDoc("3", new String[]{ "bb","aa"}, new String[]{"bbb","bbb"}, new int[]{300,400});
    addDoc("3", new String[]{ "bb","aa"}, new String[]{"aaa","ccc"}, new int[]{300,500});
    writer.commit();
    IndexReader reader = IndexReader.open(directory, true);
    searcher = new IndexSearcher(reader);
    IndexReader readerWithCache = new IndexReaderWithMetaDataCache(reader);
    searcherWithCache = new IndexSearcher(readerWithCache);
  }
View Full Code Here

Examples of org.apache.lucene.index.IndexReader

    doc.add(field);
  }
 
  public void testSimpleSearch() throws Exception
  {
    IndexReader reader = searcher.getIndexReader();
   
    BooleanQuery bquery;
    SectionSearchQuery squery;
    Scorer scorer;
    int count;
View Full Code Here

Examples of org.apache.lucene.index.IndexReader

    metaDataSearch(searcherWithCache);   
  }
 
  private void metaDataSearch(IndexSearcher searcher) throws Exception
  {
    IndexReader reader = searcher.getIndexReader();
   
    BooleanQuery bquery;
    SectionSearchQuery squery;
    Scorer scorer;
    int count;
View Full Code Here

Examples of org.apache.lucene.index.IndexReader

    }
  }
 
  public void testFacetHandlerLoad() throws Exception
  {
    IndexReader reader = IndexReader.open(_ramDir,true);
   
    List<FacetHandler<?>> list = new LinkedList<FacetHandler<?>>();
    NoopFacetHandler h1 = new NoopFacetHandler("A");
    list.add(h1);
   
View Full Code Here

Examples of org.apache.lucene.index.IndexReader

    browser.close();
  }
 
  public void testNegativeLoadTest() throws Exception
  {
    IndexReader reader = IndexReader.open(_ramDir,true);
   
    List<FacetHandler<?>> list = new LinkedList<FacetHandler<?>>();
    HashSet<String> s1 = new HashSet<String>();
    s1.add("C");
    NoopFacetHandler h1 = new NoopFacetHandler("A",s1);
View Full Code Here

Examples of org.apache.lucene.index.IndexReader

   * @param termFile Der Ort, wo die Datei erstellt werden soll.
   *
   * @throws RegainException Wenn die Erstellung fehlgeschlagen ist.
   */
  private void writeTermFile(File indexDir, File termFile) throws RegainException {
    IndexReader reader = null;
    FileOutputStream stream = null;
    PrintWriter writer = null;
    try {
      reader = IndexReader.open(FSDirectory.open(indexDir), true);

      stream = new FileOutputStream(termFile);
      writer = new PrintWriter(stream);
      writer.println("This file was generated by the crawler and contains all " + "terms in the index.");
      writer.println("It's no error when endings like 'e', 'en', and so on " + "are missing.");
      writer.println("They have been cuttet by the GermanAnalyzer and will be " + "cuttet from a search query too.");
      writer.println();

      // Write the terms
      TermEnum termEnum = reader.terms();
      int termCount;
      if (WRITE_TERMS_SORTED) {
        termCount = writeTermsSorted(termEnum, writer);
      } else {
        termCount = writeTermsSimply(termEnum, writer);
      }

      mLog.info("Wrote " + termCount + " terms into " + termFile.getAbsolutePath());
    } catch (IOException exc) {
      throw new RegainException("Writing term file failed", exc);
    } finally {
      if (reader != null) {
        try {
          reader.close();
        } catch (IOException exc) {
        }
      }
      if (writer != null) {
        writer.close();
View Full Code Here

Examples of org.apache.lucene.index.IndexReader

      Document[] data= createDataTwo();
     
      TestDataDigester testDigester=new TestDataDigester(_facetHandlers,data);
      BoboIndexer indexer=new BoboIndexer(testDigester,dir);
      indexer.index();
      IndexReader r = IndexReader.open(dir,false);
      r.close();
    } catch (UnsupportedEncodingException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
View Full Code Here

Examples of org.apache.lucene.index.IndexReader

      Document[] data= createData();
     
      TestDataDigester testDigester=new TestDataDigester(_facetHandlers,data);
      BoboIndexer indexer=new BoboIndexer(testDigester,dir);
      indexer.index();
      IndexReader r = IndexReader.open(dir,false);
      r.close();
    } catch (UnsupportedEncodingException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
View Full Code Here

Examples of org.apache.lucene.index.IndexReader

    BrowseResult result = null;
    BoboBrowser boboBrowser=null;
    int expectedHitNum = (_documentSize/2) - 1;
    try {
      Directory ramIndexDir = createIndex();
      IndexReader srcReader=IndexReader.open(ramIndexDir,true);
      boboBrowser = new BoboBrowser(BoboIndexReader.getInstance(srcReader,_facetHandlers, null));
      result = boboBrowser.browse(br);
     
      assertEquals(expectedHitNum,result.getNumHits());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.