Package com.browseengine.bobo.api

Examples of com.browseengine.bobo.api.BoboBrowser


              }
              br.setFetchStoredFields(!storedFields.isEmpty());
            }
           
           
                  BoboBrowser browser = new BoboBrowser(reader);
                 
          res=browser.browse(br);
         
        } catch (Exception e) {
          logger.error(e.getMessage(),e);
          throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,e.getMessage(),e);
        }
View Full Code Here


  public void run() {
    while (true) {
      BrowseRequest req = _iter.next();
      if (req != null) {
        BoboBrowser svc = null;
        long time = 0L;
        Exception ex = null;
        try {
          svc = new BoboBrowser(_reader);
          BrowseResult res = svc.browse(req);
          // System.out.println("num hits: "+res.getNumHits());
          getFacets(res);
          time = res.getTime();
        } catch (Exception e) {
          e.printStackTrace();
          ex = e;
        } finally {
          if (_collector != null) {
            _collector.collect(new Stats(time, ex));
          }
          try {
            svc.close();
          } catch (Exception e) {
            e.printStackTrace();
          }
        }
View Full Code Here

      try
      {
        for (int i=0;i<numIter;++i)
        {

          BoboBrowser svc = new BoboBrowser(_reader);
          BrowseRequest req = new BrowseRequest();
         
          //req.setQuery(q);
         
          //BrowseSelection sel = new BrowseSelection("ccid");
          //sel.addValue("1009");
          //req.addSelection(sel);
         
          BrowseSelection sel2 = new BrowseSelection("industry");
          sel2.addValue("4");
          req.addSelection(sel2);
         
          FacetSpec fspec = new FacetSpec();
          fspec.setExpandSelection(true);
          fspec.setMaxCount(10);
          fspec.setOrderBy(FacetSortSpec.OrderHitsDesc);
         
           req.setFacetSpec("ccid", fspec);
           req.setFacetSpec("pcid", fspec);
           req.setFacetSpec("education_id", fspec);
           req.setFacetSpec("geo_region", fspec);
           req.setFacetSpec("geo_country", fspec);
           req.setFacetSpec("industry", fspec);
           req.setFacetSpec("proposal_accepts", fspec);
           req.setFacetSpec("num_endorsers", fspec);
           //req.setFacetSpec("group_id", fspec);
          long start = System.currentTimeMillis();
         
          BrowseResult result = svc.browse(req);
          long end = System.currentTimeMillis();
          System.out.println("took: "+(end-start));
          svc.close();
         
          Thread.sleep(200);
 
        }
      }
View Full Code Here

 
  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);
    sel.addValue("/a");
    HashMap<String,String> propMap = new HashMap<String,String>();
    propMap.put(PathFacetHandler.SEL_PROP_NAME_DEPTH,"0");
    propMap.put(PathFacetHandler.SEL_PROP_NAME_STRICT,"false");
    sel.setSelectionProperties(propMap);
   
    req.addSelection(sel);
   
    FacetSpec fs = new FacetSpec();
    fs.setMinHitCount(1);
    req.setFacetSpec(PathHandlerName, fs);
   
    BrowseResult res = browser.browse(req);
    assertEquals(res.getNumHits(),1);
    FacetAccessible fa = res.getFacetAccessor(PathHandlerName);
    List<BrowseFacet> facets = fa.getFacets();
    System.out.println(facets);
    assertEquals(1,facets.size());
View Full Code Here

   
    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

    long tt = 0;
    long hitscount = 0;
    for(int x=0; x< inNumItr; x++)
    {
      long t0 = System.currentTimeMillis();
      BoboBrowser browser = new BoboBrowser(boboReader);
      BrowseRequest req = new BrowseRequest();
      req.setCount(500);
      FacetSpec spec = new FacetSpec();
      spec.setMaxCount(50);
      spec.setOrderBy(FacetSortSpec.OrderHitsDesc);
//      req.setFacetSpec("ccid", spec);
//      req.setFacetSpec("pcid", spec);
//      req.setFacetSpec("education_id", spec);
      req.setFacetSpec("geo_region", spec);
//      req.setFacetSpec("industry", spec);
      String qstr = words[nextInt()];
//      qstr = "project manager";
      String[] terms = qstr.split(" ");
      BooleanQuery q = new BooleanQuery();
    for(String s : terms)
    {
      q.add( new TermQuery(new Term("b",s)), Occur.MUST);
    }
//      q.add(new MatchAllDocsQuery(), Occur.MUST);
      req.setQuery(q);//new TermQuery(new Term("b",qstr)));
      BrowseSelection sel = new BrowseSelection("ccid");
      sel.addValue("0000001384");
//      req.addSelection(sel );
      BrowseSelection seli = new BrowseSelection("industry");
      seli.addValue("0000000052");
//      req.addSelection(seli );
      long tf0=0;
      long tf1=0;
      BrowseResult bres = browser.browse(req);
      for(Entry<String, FacetAccessible> entry: bres.getFacetMap().entrySet())
      {
//        System.out.println(entry.getKey());
        FacetAccessible fa = entry.getValue();
        tf0 = System.currentTimeMillis();
        List<BrowseFacet> facets = fa.getFacets();
        tf1=System.currentTimeMillis();
        System.out.println(tf1 - tf0 + "\tfacet "+entry.getKey()+" get time\tsize: " + facets.size());
//        System.out.println(Arrays.toString(facets.toArray()));
        fa.close();
      }
      browser.close();
//      System.out.println(t2 - t0 +"\ttotal time\t\t\t hits: "+ bres.getNumHits());
      hitscount += bres.getNumHits();
      long t2 = System.currentTimeMillis();
      tt+= (t2 - t0);
      browser.close();
//      System.out.println(t2 - t0 -(tf1-tf0)+"\tsearch time\t");
    }
    if (hitscount> 80000)System.out.println("avg hits count: " + hitscount/inNumItr);
    try
    {
View Full Code Here

   
    for (ZoieIndexReader<BoboIndexReader> reader : readerList)
    {
      List<BoboIndexReader> boboReaders = reader.getDecoratedReaders();
      for (BoboIndexReader boboReader : boboReaders){
        subBrowsableList.add(new BoboBrowser(boboReader));
      }
    }
   
    MultiBoboBrowser multiBrowser = new MultiBoboBrowser(subBrowsableList.toArray(new Browsable[subBrowsableList.size()]));
   
View Full Code Here

        throw ioe;
      }
  }

  private BoboBrowser newBrowser() throws IOException{
    return new BoboBrowser(newIndexReader());
  }
View Full Code Here

        colorSel.addValue("stored");
        br.addSelection(colorSel);
        br.setFetchStoredFields(true);
       
        BrowseResult result = null;
        BoboBrowser boboBrowser=null;
      try {
        boboBrowser=newBrowser();
       
          result = boboBrowser.browse(br);
          assertEquals(1,result.getNumHits());
          BrowseHit hit = result.getHits()[0];
          Document storedFields = hit.getStoredFields();
          assertNotNull(storedFields);
         
          String[] values = storedFields.getValues("testStored");
          assertNotNull(values);
          assertEquals(1, values.length);
          assertTrue("stored".equals(values[0]));
         
      } catch (BrowseException e) {
        e.printStackTrace();
        fail(e.getMessage());
      }
      catch(IOException ioe){
        fail(ioe.getMessage());
      }
      finally{
        if (boboBrowser!=null){
          try {
            if(result!=null) result.close();
          boboBrowser.close();
        } catch (IOException e) {
          fail(e.getMessage());
        }
        }
      }
View Full Code Here

        BrowseSelection sizeSel=new BrowseSelection("size");
        sizeSel.addValue("[4 TO 4]");
        br.addSelection(sizeSel);

        BrowseResult result = null;
        BoboBrowser boboBrowser=null;
      try {
        boboBrowser=newBrowser();
       
          result = boboBrowser.browse(br);
          assertEquals(1,result.getNumHits());
          BrowseHit hit = result.getHits()[0];
          assertNull(hit.getStoredFields());
         
          br.setFetchStoredFields(true);
          result = boboBrowser.browse(br);
          assertEquals(1,result.getNumHits());
          hit = result.getHits()[0];
          Document storedFields = hit.getStoredFields();
          assertNotNull(storedFields);
         
          String stored = storedFields.get("testStored");
          assertTrue("stored".equals(stored));
         
      } catch (BrowseException e) {
        e.printStackTrace();
        fail(e.getMessage());
      }
      catch(IOException ioe){
        fail(ioe.getMessage());
      }
      finally{
        if (boboBrowser!=null){
          try {
            if(result!=null) result.close();
          boboBrowser.close();
        } catch (IOException e) {
          fail(e.getMessage());
        }
        }
      }
View Full Code Here

TOP

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

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.