Package org.apache.lucene.index

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


      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

    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

    BrowseResult result = null;
    BoboBrowser boboBrowser=null;
   
    try {
      Directory ramIndexDir = createIndexTwo();
      IndexReader srcReader=IndexReader.open(ramIndexDir,true);
      boboBrowser = new BoboBrowser(BoboIndexReader.getInstance(srcReader,_facetHandlers, null));
     
      BrowseRequest br=new BrowseRequest();
      br.setCount(20);
      br.setOffset(0);
View Full Code Here

      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

    BrowseResult result = null;
    BoboBrowser boboBrowser=null;
    int expectedHitNum = 3;
    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());
    } catch (BrowseException e) {
View Full Code Here

  public void digest(DataHandler handler) throws IOException {
    int numcars=getMaxDocs();
    Random rand=new Random();
       
    IndexReader reader=null;
    try{
      reader=IndexReader.open(FSDirectory.open(getDataFile()),true);
      int carcount=reader.maxDoc();
     
      Document[] docCache=new Document[carcount];
      for (int i=0;i<carcount;++i){
        docCache[i]=reader.document(i);
      }
     
      for (int i=0;i<numcars;++i){
        if (i!=0 && i%1000==0){
          System.out.println(i+" cars indexed.");
        }
        Document doc=new Document();
        int n=rand.nextInt(10);
        if (n==0){
          makeCar(doc,cars[rand.nextInt(cars.length)]);         
        }
        else{
          Document srcDoc=docCache[rand.nextInt(carcount)];
          makeCar(doc,srcDoc);         
        }
       
        populateDocument(doc,null);                               
        handler.handleDocument(doc);       
      }
    }
    finally{
      if (reader!=null){
        reader.close();
      }
    }
  }
View Full Code Here

public class IndexDumper {
  private BoboIndexReader _reader;
  private int curr_docid=0;
  private int maxdoc;
  public IndexDumper(File idxDir) throws IOException{
    IndexReader idxReader=IndexReader.open(FSDirectory.open(idxDir),true);
    if (idxReader!=null){
      try{
        _reader=BoboIndexReader.getInstance(idxReader);
        maxdoc=_reader.maxDoc();
      }
      catch(Exception e){
        e.printStackTrace();
        maxdoc=0;
        idxReader.close();
      }
    }
  }
View Full Code Here

   
    File outfile = new File(_outDir,"facetvals.txt");
    BufferedOutputStream ostream = new BufferedOutputStream(new FileOutputStream(outfile));
    PrintWriter writer = new PrintWriter(new OutputStreamWriter(ostream,"UTF-8"));
   
    IndexReader reader=IndexReader.open(_idxDir);
    BoboIndexReader boboReader = BoboIndexReader.getInstance(reader);
   
    Set<String> fieldNames = boboReader.getFacetNames();
    for (String fieldName : fieldNames)
    {
      TermEnum te = reader.terms(new Term(fieldName,""));
      while(te.next())
      {
        Term t = te.term();
        if (!fieldName.equals(t.field())) break;
        writer.println(t.field()+":"+t.text());
View Full Code Here

    }
   
    Thread.sleep(10000);
   
    File indexDir = manager.getIndexDirectory();
    IndexReader indexReader = IndexReader.open(indexDir);
    String[] words = suggest.suggest("test", indexReader, DocumentCreator.FIELD_TEXT);
    assertEquals(0,words.length);
 
    words = suggest.suggest("full",indexReader,DocumentCreator.FIELD_TEXT);
    assertEquals(1,words.length);
View Full Code Here

TOP

Related Classes of org.apache.lucene.index.IndexReader

Copyright © 2018 www.massapicom. 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.