Package com.browseengine.bobo.api

Examples of com.browseengine.bobo.api.BrowseResult


    br.setOffset(0);
    br.setCount(10);
      br.setSort(new SortField[]{SortField.FIELD_SCORE});
      BoboBrowser b = newBrowser();

      BrowseResult r = b.browse(br);
     
      doTest(r, br,7,null,new String[]{"7","2","1","3","4","5","6"});

//      int firstDoc = r.getHits()[0].getDocid();
//      Explanation expl = b.explain(q, firstDoc);
View Full Code Here


// 
    BrowseRequest req = new BrowseRequest();
    BrowseFacet facet = null;
    FacetSpec facetSpec = new FacetSpec();
    req.setFacetSpec("timerange", facetSpec);
    BrowseResult result = browser.browse(req);
    FacetAccessible facetholder = result.getFacetAccessor("timerange");
    List<BrowseFacet> facets = facetholder.getFacets();
    facet = facets.get(0);
    assertEquals("order by value", "000000001", facet.getValue());
    assertEquals("order by value", 1 , facet.getFacetValueHitCount());
    facet = facets.get(1);
    assertEquals("order by value", "000010000", facet.getValue());
    assertEquals("order by value", 1 , facet.getFacetValueHitCount());
    facet = facets.get(5);
    assertEquals("order by value", "001000000", facet.getValue());
    assertEquals("order by value", 20 , facet.getFacetValueHitCount());
    facet = facets.get(7);
    assertEquals("order by value", "003000000", facet.getValue());
    assertEquals("order by value", 3 , facet.getFacetValueHitCount());
// 
    req = new BrowseRequest();
    facetSpec = new FacetSpec();
    facetSpec.setMinHitCount(0);
    facetSpec.setOrderBy(FacetSortSpec.OrderHitsDesc);
    req.setFacetSpec("timerange", facetSpec);
    result = browser.browse(req);
    facetholder = result.getFacetAccessor("timerange");
    facets = facetholder.getFacets();
    facet = facets.get(0);
    assertEquals("", "002000000", facet.getValue());
    assertEquals("", 25 , facet.getFacetValueHitCount());
    facet = facets.get(1);
    assertEquals("", "001000000", facet.getValue());
    assertEquals("", 20 , facet.getFacetValueHitCount());
    facet = facets.get(2);
    assertEquals("", "003000000", facet.getValue());
    assertEquals("", 3 , facet.getFacetValueHitCount());
    facet = facets.get(8);
    assertEquals("minCount=0", "004000000", facet.getValue());
    assertEquals("minCount=0", 0 , facet.getFacetValueHitCount());
// 
    req = new BrowseRequest();
    facetSpec = new FacetSpec();
    BrowseSelection sel = new BrowseSelection("timerange");
    sel.addValue("001000000");
    req.addSelection(sel);
    facetSpec.setExpandSelection(true);
    req.setFacetSpec("timerange", facetSpec);
    result = browser.browse(req);
    facetholder = result.getFacetAccessor("timerange");
    facets = facetholder.getFacets();
    facet = facets.get(0);
    assertEquals("", "000000001", facet.getValue());
    assertEquals("", 1 , facet.getFacetValueHitCount());
    facet = facets.get(6);
    assertEquals("", "002000000", facet.getValue());
    assertEquals("", 25 , facet.getFacetValueHitCount());
    facet = facets.get(7);
    assertEquals("", "003000000", facet.getValue());
    assertEquals("", 3 , facet.getFacetValueHitCount());
// 
    req = new BrowseRequest();
    facetSpec = new FacetSpec();
    sel = new BrowseSelection("timerange");
    sel.addValue("001000000");
    sel.addValue("003000000");
    sel.addValue("004000000");
    req.addSelection(sel );
    facetSpec.setExpandSelection(false);
    req.setFacetSpec("timerange", facetSpec);
    result = browser.browse(req);
    facetholder = result.getFacetAccessor("timerange");
    facet = facetholder.getFacet("001000000");
    assertEquals("001000000", 20, facet.getFacetValueHitCount());
    facet = facetholder.getFacet("003000000");
    assertEquals("003000000", 3, facet.getFacetValueHitCount());
    facet = facetholder.getFacet("004000000");
    assertEquals("004000000", 0, facet.getFacetValueHitCount());
    assertEquals("",23,result.getNumHits());
  }
View Full Code Here

    BrowseSelection idSel=new BrowseSelection("id");
    idSel.addNotValue("0");
    br.addSelection(idSel);

    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());

      StringBuilder buffer=new StringBuilder();
      BrowseHit[] hits=result.getHits();
    
      for (int i=0;i<hits.length;++i)
      {
        int expectedID = (i+1)*2;
        assertEquals(expectedID, Integer.parseInt(hits[i].getField("id")));
        if (i!=0){
          buffer.append('\n');
        }
        buffer.append("id=" + hits[i].getField("id") + "," + "color=" + hits[i].getField("color"));
      }
      log.info(buffer.toString());

    } 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 testNotValuesForRangeFacetHandler() throws Exception{
    System.out.println("testNotValuesForRangeFacetHandler");
    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);

      if(_idRanges==null)
      {
        log.error("_idRanges cannot be null in order to test NOT on RangeFacetHandler");
      }
      BrowseSelection idSel=new BrowseSelection("idRange");
      int rangeIndex = 2;
      idSel.addNotValue(_idRanges[0]);
      int expectedHitNum = 1;
      br.addSelection(idSel);
      BooleanQuery q = new BooleanQuery();
      q.add(NumericRangeQuery.newIntRange("NUM", 10, 10, true, true), Occur.MUST_NOT);
      q.add(new MatchAllDocsQuery(), Occur.MUST);
      br.setQuery(q);
     
      result = boboBrowser.browse(br);
     
      assertEquals(expectedHitNum,result.getNumHits());
      for(int i=0; i<result.getNumHits();i++)
      {
        System.out.println(result.getHits()[i]);
      }

    } 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.setFacetSpec("mycolor", spec);
    br.setFacetSpec("id", spec);
    br.setFacetSpec("make", spec);

    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) {
      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

    long time = result.getTime();
    int numhits = result.getNumhits();
    int totaldocs = result.getTotaldocs();
    List<BrowseResultBPO.FacetContainer> facetList = result.getFacetContainersList();
    List<BrowseResultBPO.Hit> hitList = result.getHitsList();
    BrowseResult res = new BrowseResult();
    res.setTime(time);
    res.setTotalDocs(totaldocs);
    res.setNumHits(numhits);
    for (BrowseResultBPO.FacetContainer facetContainer : facetList)
    {
      res.addFacets(facetContainer.getName(), new FacetContainerAccessible(facetContainer));
    }
   
    BrowseHit[] browseHits = new BrowseHit[hitList==null ? 0 : hitList.size()];
    int i=0;
    for (BrowseResultBPO.Hit hit : hitList)
    {
      browseHits[i++] = convert(hit);
    }
    res.setHits(browseHits);
    return res;
  }
View Full Code Here

      i++;
      docId = iterator.nextDoc();
    }
    assertEquals(Arrays.toString(new int[] { 1, 2 }), Arrays.toString(docIds));

    BrowseResult res = browser.browse(request);
    assertEquals(res.getNumHits(), 2);
    FacetAccessible fa = res.getFacetAccessor(AttributeHandlerName);
    List<BrowseFacet> facets = fa.getFacets();
    System.out.println(facets);
    assertEquals(3, facets.size());
    BrowseFacet facet = facets.get(0);
    assertEquals(1, facet.getFacetValueHitCount());
View Full Code Here

    assertEquals(1, facet.getFacetValueHitCount());
  }

  public void test2PropertyRetrieval() throws Exception {
    BrowseRequest request = createRequest(1, "prop3");
    BrowseResult res = browser.browse(request);
    assertEquals(res.getNumHits(), 2);
    assertEquals(res.getHits()[0].getDocid(), 1);
    assertEquals(res.getHits()[1].getDocid(), 2);
    List<BrowseFacet> facets = res.getFacetAccessor(AttributeHandlerName).getFacets();
    assertEquals(facets.size(), 3);
    assertEquals(facets.get(0).getValue(), "prop3=val1");
    assertEquals(facets.get(0).getFacetValueHitCount(), 1);
    assertEquals(facets.get(2).getValue(), "prop3=val3");
    assertEquals(facets.get(2).getFacetValueHitCount(), 1);
View Full Code Here

    assertEquals(facets.get(2).getFacetValueHitCount(), 1);
  }

  public void test3PropertyInEachDocRetrieval() throws Exception {
    BrowseRequest request = createRequest(1, "prop1");
    BrowseResult res = browser.browse(request);
    assertEquals(res.getNumHits(), 6);
    assertEquals(res.getHits()[0].getDocid(), 0);
    assertEquals(res.getHits()[5].getDocid(), 5);
    List<BrowseFacet> facets = res.getFacetAccessor(AttributeHandlerName).getFacets();
    assertEquals(facets.size(), 2);
    assertEquals(facets.get(0).getValue(), "prop1=val1");
    assertEquals(facets.get(0).getFacetValueHitCount(), 4);
    assertEquals(facets.get(1).getValue(), "prop1=val2");
    assertEquals(facets.get(1).getFacetValueHitCount(), 2);
View Full Code Here

    assertEquals(facets.get(1).getFacetValueHitCount(), 2);
  }

  public void test4PropertyInFirstDocRetrieval() throws Exception {
    BrowseRequest request = createRequest(1, "prop5");
    BrowseResult res = browser.browse(request);
    assertEquals(res.getNumHits(), 1);
    assertEquals(res.getHits()[0].getDocid(), 0);

    List<BrowseFacet> facets = res.getFacetAccessor(AttributeHandlerName).getFacets();
    assertEquals(facets.size(), 1);
    assertEquals(facets.get(0).getValue(), "prop5=val1");
    assertEquals(facets.get(0).getFacetValueHitCount(), 1);
  }
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.