Package com.browseengine.bobo.api

Examples of com.browseengine.bobo.api.BrowseFacet


    ranges.add("004000000");
    FacetHandler<?> facetHandler = new DynamicTimeRangeFacetHandler("timerange", "timeinmillis", now, ranges );
    browser.setFacetHandler(facetHandler );
// 
    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


      output.setMinHitCount(1);
      br.setFacetSpec("numberhisto", output);
     
     
      BrowseFacet[] answerBucketFacets = new BrowseFacet[5];    
      answerBucketFacets[0] new BrowseFacet("0000000000", 3);
      answerBucketFacets[1] new BrowseFacet("0000000002", 1);
      answerBucketFacets[2] new BrowseFacet("0000000009", 1);
      answerBucketFacets[3] new BrowseFacet("0000000010",1);
      answerBucketFacets[4] new BrowseFacet("0000000021",1);
     
        HashMap<String,List<BrowseFacet>> answer = new HashMap<String,List<BrowseFacet>>();
        answer.put("numberhisto", Arrays.asList(answerBucketFacets));
     
     
        doTest(br,7,answer,null);
       
       
        // now with selection
       
        BrowseSelection sel = new BrowseSelection("color");
        sel.addValue("green");
        br.addSelection(sel);
       
        answerBucketFacets = new BrowseFacet[2];
        answerBucketFacets[0] new BrowseFacet("0000000002",1);
        answerBucketFacets[1] new BrowseFacet("0000000021",1);
       
        answer = new HashMap<String,List<BrowseFacet>>();
        answer.put("numberhisto", Arrays.asList(answerBucketFacets));
     
     
View Full Code Here

        FacetSpec output=new FacetSpec();
        output.setOrderBy(FacetSortSpec.OrderHitsDesc);
        br.setFacetSpec("sets", output);
       
        BrowseFacet[] answerBucketFacets = new BrowseFacet[3];    
        answerBucketFacets[0] new BrowseFacet("s1", 5);
        answerBucketFacets[1] new BrowseFacet("s2", 4);
        answerBucketFacets[2] new BrowseFacet("s3", 3);
       
          HashMap<String,List<BrowseFacet>> answer = new HashMap<String,List<BrowseFacet>>();
          answer.put("sets", Arrays.asList(answerBucketFacets));
        doTest(br,7,answer,null);
       
        br=new BrowseRequest();
        br.setCount(10);
        br.setOffset(0);
       
        BrowseSelection sel=new BrowseSelection("sets");
          sel.addValue("s1");
          br.addSelection(sel);
       
        output=new FacetSpec();
        output.setOrderBy(FacetSortSpec.OrderHitsDesc);
        br.setFacetSpec("sets", output);
       
        answerBucketFacets = new BrowseFacet[3];    
        answerBucketFacets[0] new BrowseFacet("s1", 5);
        answerBucketFacets[1] new BrowseFacet("s2", 3);
        answerBucketFacets[2] new BrowseFacet("s3", 1);
       
          answer = new HashMap<String,List<BrowseFacet>>();
          answer.put("sets", Arrays.asList(answerBucketFacets));
        doTest(br,4,answer,null);
   }
View Full Code Here

      FacetSpec output=new FacetSpec();
      output.setOrderBy(FacetSortSpec.OrderHitsDesc);
      br.setFacetSpec("groups", output);
     
      BrowseFacet[] answerBucketFacets = new BrowseFacet[3];    
      answerBucketFacets[0] new BrowseFacet("g2", 3);
      answerBucketFacets[1] new BrowseFacet("g1", 1);
      answerBucketFacets[2] new BrowseFacet("g3", 1);
     
        HashMap<String,List<BrowseFacet>> answer = new HashMap<String,List<BrowseFacet>>();
        answer.put("groups", Arrays.asList(answerBucketFacets));
      doTest(br,3,answer,null);
     
      br=new BrowseRequest();
      br.setCount(10);
      br.setOffset(0);
     
      sel=new BrowseSelection("groups");
        sel.addValue("g2");
        sel.addValue("g1");
        sel.setSelectionOperation(ValueOperation.ValueOperationAnd);
        br.addSelection(sel);
   
      output=new FacetSpec();
      output.setOrderBy(FacetSortSpec.OrderHitsDesc);
      br.setFacetSpec("groups", output);
     
      answerBucketFacets = new BrowseFacet[2];    
      answerBucketFacets[0] new BrowseFacet("g1", 1);
      answerBucketFacets[1] new BrowseFacet("g2", 1);
     
      answer = new HashMap<String,List<BrowseFacet>>();
      answer.put("groups", Arrays.asList(answerBucketFacets));
      doTest(br,1,answer,null);
     
      br=new BrowseRequest();
      br.setCount(10);
      br.setOffset(0);
     
      sel=new BrowseSelection("groups");
        sel.addValue("g2");
        sel.addValue("g1");
        sel.setSelectionOperation(ValueOperation.ValueOperationOr);
        br.addSelection(sel);
   
      output=new FacetSpec();
      output.setOrderBy(FacetSortSpec.OrderHitsDesc);
      br.setFacetSpec("groups", output);
     
      answerBucketFacets = new BrowseFacet[3];    
      answerBucketFacets[0] new BrowseFacet("g1", 3);
      answerBucketFacets[1] new BrowseFacet("g2", 3);
      answerBucketFacets[2] new BrowseFacet("g3", 1);
     
      answer = new HashMap<String,List<BrowseFacet>>();
      answer.put("groups", Arrays.asList(answerBucketFacets));
      doTest(br,5,answer,null);
   
View Full Code Here

      _data = new HashMap<String,BrowseFacet>();
      if (facetContainer!=null){
        List<BrowseResultBPO.Facet> facetList = facetContainer.getFacetsList();
        if (facetList!=null){
          for (BrowseResultBPO.Facet facet : facetList){
            BrowseFacet bfacet = new BrowseFacet();
            String val = facet.getVal();
            bfacet.setValue(val);
            bfacet.setFacetValueHitCount(facet.getCount());
            _data.put(val,bfacet);
          }
        }
      }
    }
View Full Code Here

      hit.setScore(fdoc.score);
      hit.setComparable(fdoc.getValue());
      if (groupBy != null) {
        hit.setGroupValue(hit.getField(groupBy.getName()));
        if (hit.getGroupValue() != null && groupAccessible != null) {
          BrowseFacet facet = groupAccessible.getFacet(hit.getGroupValue());
          hit.setGroupHitsCount(facet.getFacetValueHitCount());
        }
      }
      hits[i] = hit;
    }
    return hits;
View Full Code Here

    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(res.getNumHits(), 1);
    FacetAccessible fa = res.getFacetAccessor(PathHandlerName);
    List<BrowseFacet> facets = fa.getFacets();
    System.out.println(facets);
    assertEquals(1, facets.size());
    BrowseFacet facet = facets.get(0);
    assertEquals(2, facet.getFacetValueHitCount());
  }
View Full Code Here

        hit.setGroupField(groupBy.getName());
        hit.setGroupValue(hit.getField(groupBy.getName()));
        hit.setRawGroupValue(hit.getRawField(groupBy.getName()));
        if (groupAccessibles != null && hit.getGroupValue() != null && groupAccessibles != null
            && groupAccessibles.length > 0) {
          BrowseFacet facet = groupAccessibles[0].getFacet(hit.getGroupValue());
          hit.setGroupHitsCount(facet.getFacetValueHitCount());
        }
      }
      hits[i] = hit;
    }
    return hits;
View Full Code Here

            if (l1.size() == l2.size()) {
              Iterator<BrowseFacet> iter1 = l1.iterator();
              Iterator<BrowseFacet> iter2 = l2.iterator();
              while (iter1.hasNext()) {
                BrowseFacet bf1 = iter1.next();
                BrowseFacet bf2 = iter2.next();
                // if (!iter1.next().equals(iter2.next()))
                if (!bf1.equals(bf2)) {
                  return false;
                }
              }
View Full Code Here

TOP

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

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.