Package com.browseengine.bobo.api

Examples of com.browseengine.bobo.api.BoboIndexReader


    {

      SolrIndexSearcher searcher=rb.req.getSearcher();
     
      SolrIndexReader solrReader = searcher.getReader();
      BoboIndexReader reader = (BoboIndexReader)solrReader.getWrappedReader();
     
      if (reader instanceof BoboIndexReader){
          try {
            List<Query> filters = rb.getFilters();
            if (filters!=null){
              final ArrayList<DocIdSet> docsets = new ArrayList<DocIdSet>(filters.size());
                for (Query filter : filters){
                  Weight weight = filter.createWeight(rb.req.getSearcher());
                  final Scorer scorer = weight.scorer(reader, false, true);
                  docsets.add(new DocIdSet(){
                @Override
                public DocIdSetIterator iterator() throws IOException {
                  return scorer;
                }
                   
                  });
                }
               
                if (docsets.size()>0){
                  br.setFilter(
                    new Filter(){
                @Override
                public DocIdSet getDocIdSet(IndexReader reader)
                    throws IOException {
                  return new AndDocIdSet(docsets);
                }
                  });
                }
            }
             
            Set<String> facetNames = reader.getFacetNames();
            Set<String> returnFields = rb.rsp.getReturnFields();
            Set<String> storedFields = new HashSet<String>();
            if (returnFields!=null){
              for (String fld : returnFields){
              if (!facetNames.contains(fld)){
View Full Code Here


      @Override
      public DocComparator getComparator(IndexReader reader, int docbase)
          throws IOException {
        final UIDFacetHandler uidFacetHandler = UIDFacetHandler.this;
        if (reader instanceof BoboIndexReader){
          BoboIndexReader boboReader = (BoboIndexReader)reader;
          final long[] uidArray = uidFacetHandler.getFacetData(boboReader);
          return new DocComparator() {
           
            @Override
            public Comparable value(ScoreDoc doc) {
View Full Code Here

    FSDirectory idxDir = FSDirectory.open(file);
   
    IndexReader reader = IndexReader.open(idxDir,true);
   
    long start =System.currentTimeMillis();
    BoboIndexReader boboReader = BoboIndexReader.getInstance(reader);

    long end =System.currentTimeMillis();
   
    System.out.println("load took: "+(end-start));
    int numThreads = 10;
View Full Code Here

      facetHandlers.add(pathHandler);
  }
 
  public void testMultiValPath() throws Exception{
    IndexReader reader = IndexReader.open(directory,true);
    BoboIndexReader boboReader = BoboIndexReader.getInstance(reader, facetHandlers);
   
    BoboBrowser browser = new BoboBrowser(boboReader);
    BrowseRequest req = new BrowseRequest();
   
    BrowseSelection sel = new BrowseSelection(PathHandlerName);
View Full Code Here

    File idx = new File("/Users/jwang/dataset/people-search-index-norm/beef");
   
    Directory idxDir = FSDirectory.open(idx);
    IndexReader reader=IndexReader.open(idxDir,true);
   
    BoboIndexReader boboReader=BoboIndexReader.getInstance(reader);
    BoboBrowser browser=new BoboBrowser(boboReader);
    int iter=1000000;
    for (int i=0;i<iter;++i)
    {
      doBrowse(browser);
View Full Code Here

//    facetHandlers.add(new MultiValueFacetHandler("pcid", new PredefinedTermListFactory<Integer>(Integer.class,"0000000000")));
    facetHandlers.add(new SimpleFacetHandler("industry", new PredefinedTermListFactory<Integer>(Integer.class,"0000000000")));
    facetHandlers.add(new SimpleFacetHandler("geo_region"));
    facetHandlers.add(new MultiValueFacetHandler("education_id", new PredefinedTermListFactory<Integer>(Integer.class,"0000000000")));
    long tgetinstance = System.currentTimeMillis();
    final BoboIndexReader boboReader = BoboIndexReader.getInstance(reader, facetHandlers , null);
    System.out.println("getInstanceTime: " + (System.currentTimeMillis() - tgetinstance));
//warming
    for(int x=0; x<30; x++)
    {
      doSearch(5, boboReader, facetHandlers);
View Full Code Here

  }
 
  private BoboIndexReader newIndexReader(boolean readonly) throws IOException{
    IndexReader srcReader=IndexReader.open(_indexDir,readonly);
      try{
        BoboIndexReader reader= BoboIndexReader.getInstance(srcReader,_fconf, null);
        return reader;
      }
      catch(IOException ioe){
        if (srcReader!=null){
          srcReader.close();
View Full Code Here

    IndexReader srcReader=IndexReader.open(_indexDir,true);
      try{
        List<FacetHandler<?>> facetHandlers = new ArrayList<FacetHandler<?>>();
        facetHandlers.add(new SimpleFacetHandler("id"));
       
        BoboIndexReader reader= BoboIndexReader.getInstance(srcReader,facetHandlers, null);       // not facet handlers to help
        BoboBrowser browser = new BoboBrowser(reader);
       
        BrowseRequest browseRequest = new BrowseRequest();
        browseRequest.setCount(10);
        browseRequest.setOffset(0);
View Full Code Here

     
  }

  public void testBrowseWithDeletes()
  {
    BoboIndexReader reader = null;

    BrowseRequest br = new BrowseRequest();
    br.setCount(10);
    br.setOffset(0);

    BrowseSelection sel = new BrowseSelection("color");
    sel.addValue("red");
    br.addSelection(sel);
    HashMap<String, List<BrowseFacet>> answer = new HashMap<String, List<BrowseFacet>>();

    doTest(br, 3, answer, new String[] {"1", "2", "7"});

    try
    {
      reader = newIndexReader(false);
      reader.deleteDocuments(new Term("id", "1"));
      reader.deleteDocuments(new Term("id", "2"));
     
      br = new BrowseRequest();
      br.setCount(10);
      br.setOffset(0);

      sel = new BrowseSelection("color");
      sel.addValue("red");
      br.addSelection(sel);
      answer = new HashMap<String, List<BrowseFacet>>();

      doTest(new BoboBrowser(reader), br, 1, answer, null);
    }
    catch (IOException ioe)
    {
      fail(ioe.getMessage());
    }
    finally
    {
      if (reader != null)
      {
        try
        {
          reader.close();
        }
        catch (IOException e)
        {
          fail(e.getMessage());
        }
View Full Code Here

    writer.addDocument(docs[0]);
    writer.optimize();
    writer.commit();
   
    IndexReader idxReader = IndexReader.open(idxDir,true);
    BoboIndexReader boboReader = BoboIndexReader.getInstance(idxReader,_fconf);

   
    for (int i=1;i<docs.length;++i){
      Document doc = docs[i];
      int numDocs = boboReader.numDocs();
      BoboIndexReader reader = (BoboIndexReader)boboReader.reopen(true);
      assertSame(boboReader,reader);
     
      Directory tmpDir = new RAMDirectory();
      IndexWriter subWriter = new IndexWriter(tmpDir,new StandardAnalyzer(Version.LUCENE_29),MaxFieldLength.UNLIMITED);
      subWriter.addDocument(doc);
      subWriter.optimize();
      subWriter.close();
      writer.addIndexesNoOptimize(new Directory[]{tmpDir});
      writer.commit();
      reader = (BoboIndexReader)boboReader.reopen();
      assertNotSame(boboReader, reader);
      assertEquals(numDocs+1,reader.numDocs());
      boboReader = reader;
    }
    writer.deleteDocuments(new Term("id","1"));
    writer.commit();
    int numDocs = boboReader.numDocs();
    BoboIndexReader newReader = (BoboIndexReader)boboReader.reopen();
    assertNotSame(newReader,boboReader);
    int numDocs2 = newReader.numDocs();
    if (boboReader!=newReader){
      boboReader.close();
      boboReader = newReader;
    }
    assertEquals(numDocs-1,numDocs2);
View Full Code Here

TOP

Related Classes of com.browseengine.bobo.api.BoboIndexReader

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.