public BrowseResult browse(BrowseRequest req) {
   BoboBrowser browser = null;
   try {
     browser = new BoboBrowser(_boboReader);
     return browser.browse(req);
   } catch (Exception e) {
     logger.error(e.getMessage(), e);
     return new BrowseResult();
   } finally {
     if (browser != null) {
       try {
         browser.close();
       } catch (IOException e) {
         logger.error(e.getMessage());
       }
     }
   }
 }
Esempio n. 2
0
  /*
  * [00000001371(3156), 00000001025(2951), 00000001035(2688), 00000001009(2429), 00000157234(2318), 00000001028(1871),
  *  00000001063(1711), 00000002114(1371), 00000001033(1340), 00000001384(1187), 00000001292(1016), 00000001694(993),
  *   00000001483(980), 00000001062(884), 00000001115(883), 00000001441(854), 00000001052(695), 00000001093(681),
  *    00000001714(665), 00000001128(641), 00000224605(619), 00000001053(616), 00000002271(613), 00000001288(609),
  *     00000001038(607), 00000001060(585), 00000001043(573), 00000157240(555), 00000001044(549), 00000001663(546),
  *      00000001231(544), 00000001123(526), 00000001505(497), 00000001120(487), 00000001070(484), 00000001217(480),
  *      00000001073(478), 00000001006(452), 00000001068(437), 00000001207(432), 00000001066(415), 00000001116(415),
  *       00000001271(415), 00000001015(407), 00000011448(401), 00000001040(399), 00000001235(393), 00000001058(391),
  *        00000001482(382), -00000000001(0)]

  */
  private static long oneRun(BoboIndexReader boboReader, Collection<FacetHandler<?>> facetHandlers)
      throws IOException, BrowseException {
    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 {
      Thread.sleep(50);
    } catch (InterruptedException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    return tt;
  }