Package com.browseengine.bobo.api

Examples of com.browseengine.bobo.api.BrowseResult


      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");
    }
View Full Code Here


    try
    {
      readerList = _indexReaderFactory.getIndexReaders();
      browsable = new MultiBoboBrowser(BoboBrowser.createBrowsables(ZoieIndexReader.extractDecoratedReaders(readerList)));
     
      BrowseResult res = browsable.browse(req);
     
      BrowseResult serializableResult = new BrowseResult();
      serializableResult.setHits(res.getHits());
      serializableResult.setNumHits(res.getNumHits());
      serializableResult.setTotalDocs(res.getTotalDocs());
      serializableResult.setTime(res.getTime());
     
      Map<String,FacetAccessible> facetMap = res.getFacetMap();
      Set<Entry<String,FacetAccessible>> entries = facetMap.entrySet();
      for (Entry<String,FacetAccessible> entry : entries)
      {
        List<BrowseFacet> facets = entry.getValue().getFacets();
        SerializedFacetAccessible facetAccessible = new SerializedFacetAccessible(facets);
        serializableResult.addFacets(entry.getKey(), facetAccessible);
      }
      return serializableResult;
    }
    catch(IOException ioe)
    {
View Full Code Here

        BrowseSelection colorSel=new BrowseSelection("testStored");
        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

  public void testRawDataRetrieval() throws Exception{
    BrowseRequest br=new BrowseRequest();
    br.setCount(10);
    br.setOffset(0);
    br.setSort(new SortField[]{new SortField("date",SortField.CUSTOM,false)});
    BrowseResult result = null;
        BoboBrowser boboBrowser=null;
        SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy/MM/dd");
      try {
        boboBrowser=newBrowser();
       
          result = boboBrowser.browse(br);
          assertEquals(7,result.getNumHits());
          BrowseHit hit = result.getHits()[0];
          assertEquals(0,hit.getDocid());
          Object lowDate = hit.getRawField("date");
          Date date = dateFormatter.parse("2000/01/01");
          assertTrue(lowDate.equals(date.getTime()));
         
          hit = result.getHits()[6];
          assertEquals(5,hit.getDocid());
          Object highDate = hit.getRawField("date");
          date = dateFormatter.parse("2007/08/01");
          assertTrue(highDate.equals(date.getTime()));
         
      } 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

  private BrowseResult  doTest(BrowseRequest req,int numHits,HashMap<String,List<BrowseFacet>> choiceMap,String[] ids){
    return doTest((BoboBrowser)null,req,numHits,choiceMap,ids);
    }
 
  private BrowseResult doTest(BoboBrowser boboBrowser,BrowseRequest req,int numHits,HashMap<String,List<BrowseFacet>> choiceMap,String[] ids) {
      BrowseResult result = null;
      try {
          if (boboBrowser==null) {
        boboBrowser=newBrowser();
        }
          result = boboBrowser.browse(req);
          doTest(result,req,numHits,choiceMap,ids);
          return result;// result;
      } 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

      br.setOffset(0);
      br.setFacetSpec("number",new FacetSpec());
     
      BoboBrowser browser = newBrowser();
     
      BrowseResult res=browser.browse(br);
      FacetAccessible facetAccessor = res.getFacetAccessor("number");
      BrowseFacet facet = facetAccessor.getFacet("5");
     
      assertEquals(facet.getValue(), "0005");
      assertEquals(facet.getFacetValueHitCount(), 1);
      res.close();
  }
View Full Code Here

      br.setQuery(parser.parse("color:red OR shape:square"));
        br.setCount(10);
        br.setOffset(0);
       
        br.setSort(new SortField[]{SortField.FIELD_SCORE});
        BrowseResult res = doTest(br,4,null,new String[]{"1","7","2","5"});
       
        BrowseHit[] hits = res.getHits();
        for (BrowseHit hit : hits){
          assertNull(hit.getExplanation());
        }
       
        br.setShowExplanation(true);
        res = doTest(br,4,null,new String[]{"1","7","2","5"});
        hits = res.getHits();
        for (BrowseHit hit : hits){
          assertNotNull(hit.getExplanation());
        }
       
        Query rawQuery = br.getQuery();
       
          SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd");
        Date d = format.parse("2006/06/01");
        long fromTime = d.getTime();
       
        RecencyBoostScorerBuilder recencyBuilder = new RecencyBoostScorerBuilder("date", 2.0f, TimeUnit.DAYS.convert(fromTime,TimeUnit.MILLISECONDS), 30L, TimeUnit.DAYS);
        ScoreAdjusterQuery sq = new ScoreAdjusterQuery(rawQuery,recencyBuilder);
        br.setQuery(sq);
       
          res = doTest(br,4,null,new String[]{"7","1","2","5"});
       
        hits = res.getHits();
        for (BrowseHit hit : hits){
          assertNotNull(hit.getExplanation());
          System.out.println(hit.getExplanation());
        }
       
View Full Code Here

      BoboBrowser boboBrowser = newBrowser();
     
      browseRequest.setSort(new SortField[]{new SortField("compactnum",SortField.CUSTOM,true)});
     
      MultiBoboBrowser multiBoboBrowser = new MultiBoboBrowser(new Browsable[] {boboBrowser, boboBrowser});
      BrowseResult mergedResult = multiBoboBrowser.browse(browseRequest);
     
      HashMap<String,List<BrowseFacet>> answer=new HashMap<String,List<BrowseFacet>>();
      answer.put("color", Arrays.asList(new BrowseFacet[]{new BrowseFacet("red",4),new BrowseFacet("green",2)}));
      answer.put("tag", Arrays.asList(new BrowseFacet[]{new BrowseFacet("animal",2),new BrowseFacet("dog",2),new BrowseFacet("humane",2),new BrowseFacet("pet",2),new BrowseFacet("rabbit",4)}));
      answer.put("shape", Arrays.asList(new BrowseFacet[]{new BrowseFacet("square",4)}));
      answer.put("date",  Arrays.asList(new BrowseFacet[]{new BrowseFacet("[2000/01/01 TO 2003/05/05]", 2)}));
     
      doTest(mergedResult, browseRequest, 4, answer, new String[]{"7","7","1","1"});
     
      browseRequest.setSort(new SortField[]{new SortField("multinum",SortField.CUSTOM,true)});
      mergedResult = multiBoboBrowser.browse(browseRequest);
      doTest(mergedResult, browseRequest, 4, answer, new String[]{"7","7","1","1"});
      mergedResult.close();
      multiBoboBrowser.close();
  }
View Full Code Here

    br.setQuery(bq);
    br.setOffset(0);
    br.setCount(10);
   
   
    BrowseResult res = doTest(br,6,null,new String[]{"4","1","7","5","3","2"});
    BrowseHit[] hits = res.getHits();
    float[] scores = new float[]{13,11,11,10,4.5f,2.5f}// default coord = 1/2
    for (int i=0;i<hits.length;++i){
      assertEquals(scores[i],hits[i].getScore());
    }
  }
View Full Code Here

TOP

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

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.