Package com.browseengine.bobo.api

Examples of com.browseengine.bobo.api.BrowseFacet


              if (countStr!=null){
                fcount = Integer.parseInt(countStr);
              }
              BrowseFacet[] facets = new BrowseFacet[fcount];
              for (int k=0;k<fcount;++k){
                facets[k]=new BrowseFacet();
                reader.moveDown();
                String valueString=reader.getAttribute("value");
                facets[k].setValue(valueString);
               
                String countString=reader.getAttribute("count");
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(1,facet.getFacetValueHitCount());
  }
View Full Code Here

              {
                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

    output.setExpandSelection(true);
    br.setFacetSpec("color", output);
    br.setFacetSpec("shape", output);
   
    HashMap<String,List<BrowseFacet>> answer=new HashMap<String,List<BrowseFacet>>();
        answer.put("color", Arrays.asList(new BrowseFacet[]{new BrowseFacet("blue",2),new BrowseFacet("green",2),new BrowseFacet("red",3)}));
        answer.put("shape", Arrays.asList(new BrowseFacet[]{new BrowseFacet("rectangle",1),new BrowseFacet("square",2)}));
       
        doTest(br,3,answer,new String[]{"1","2","7"});

        sel=new BrowseSelection("shape");
        sel.addValue("square");
        br.addSelection(sel);
   
    answer=new HashMap<String,List<BrowseFacet>>();
    answer.put("color", Arrays.asList(new BrowseFacet[]{new BrowseFacet("blue",1),new BrowseFacet("red",2)}));
    answer.put("shape", Arrays.asList(new BrowseFacet[]{new BrowseFacet("rectangle",1),new BrowseFacet("square",2)}));
   
    doTest(br,2,answer,new String[]{"1","7"});
  }
View Full Code Here

    FacetSpec pathSpec=new FacetSpec();
    pathSpec.setOrderBy(FacetSortSpec.OrderValueAsc);
    br.setFacetSpec("path", pathSpec);
   
    HashMap<String,List<BrowseFacet>> answer=new HashMap<String,List<BrowseFacet>>();
    answer.put("path", Arrays.asList(new BrowseFacet[]{new BrowseFacet("a-b",1),new BrowseFacet("a-c",4),new BrowseFacet("a-e",2)}));
    doTest(br,7,answer,null);
   
    pathSpec.setOrderBy(FacetSortSpec.OrderHitsDesc);
    answer=new HashMap<String,List<BrowseFacet>>();
    answer.put("path", Arrays.asList(new BrowseFacet[]{new BrowseFacet("a-c",4),new BrowseFacet("a-e",2),new BrowseFacet("a-b",1)}));
    doTest(br,7,answer,null);
   
    pathSpec.setMaxCount(2);
    answer=new HashMap<String,List<BrowseFacet>>();
    answer.put("path", Arrays.asList(new BrowseFacet[]{new BrowseFacet("a-c",4),new BrowseFacet("a-e",2)}));
    doTest(br,7,answer,null);
  }
View Full Code Here

    FacetSpec geoSpec=new FacetSpec();
    geoSpec.setOrderBy(FacetSortSpec.OrderValueAsc);
    br.setFacetSpec("distance", geoSpec);
   
    HashMap<String,List<BrowseFacet>> answer=new HashMap<String,List<BrowseFacet>>();
    answer.put("distance", Arrays.asList(new BrowseFacet[]{new BrowseFacet("30,70:5",2),new BrowseFacet("60,120:1",2)}));
    doTest(br,4,answer,null);

    // testing for selection of facet <60,120,1> and verifying that 2 documents match this facet.
    BrowseRequest br2 = new BrowseRequest();
    br2.setCount(10);
    br2.setOffset(0)

    BrowseSelection sel2 = new BrowseSelection("distance");
    sel2.addValue("60,120:1");
    HashMap<String, Float> map = new HashMap<String, Float>();
    map.put("0,120:1", 3.0f);
    FacetTermQuery geoQ = new FacetTermQuery(sel2,map);
   
    BoboBrowser b = newBrowser();
    Explanation expl = b.explain(geoQ, 0);
   
    br2.setQuery(geoQ);
    doTest(br2,2,null,new String[]{"1","5"});
    expl = b.explain(geoQ, 1);
     
      // facet query for color "red" and getting facet counts for the distance facet.
    BrowseRequest br3 = new BrowseRequest();
    br3.setCount(10);
    br3.setOffset(0)

    BrowseSelection sel3 = new BrowseSelection("color");
    sel3.addValue("red");
    HashMap<String, Float> map3 = new HashMap<String, Float>();
    map3.put("red", 3.0f);
    FacetTermQuery colorQ = new FacetTermQuery(sel3,map3);

    BoboBrowser b2 = newBrowser();
    Explanation expl2 = b.explain(colorQ, 0);
   
    br3.setFacetSpec("distance", geoSpec);
    geoSpec.setMinHitCount(0);
    br3.setQuery(colorQ);             // query is color=red
    br3.addSelection(sel);        // count facets <30,70,5> and <60,120,1>
    answer.clear();
    answer.put("distance", Arrays.asList(new BrowseFacet[]{new BrowseFacet("30,70:5", 0), new BrowseFacet("60,120:1",1)}));   
    doTest(br3, 1 , answer, null);

  }
View Full Code Here

    geoSpec.setMinHitCount(0);
    geoSpec.setOrderBy(FacetSortSpec.OrderValueAsc);
    br.setFacetSpec("correctDistance", geoSpec);
   
    HashMap<String,List<BrowseFacet>> answer=new HashMap<String,List<BrowseFacet>>();
    answer.put("correctDistance", Arrays.asList(new BrowseFacet[]{new BrowseFacet("30,75:100",1),new BrowseFacet("60,120:1",2)}));
    doTest(br,3,answer,null);

    // testing for selection of facet <60,120,1> and verifying that 2 documents match this facet.
    BrowseRequest br2 = new BrowseRequest();
    br2.setCount(10);
    br2.setOffset(0)

    BrowseSelection sel2 = new BrowseSelection("correctDistance");
    sel2.addValue("60,120:1");
    HashMap<String, Float> map = new HashMap<String, Float>();
    map.put("60,120:1", 3.0f);
    FacetTermQuery geoQ = new FacetTermQuery(sel2,map);
   
    BoboBrowser b = newBrowser();
    Explanation expl = b.explain(geoQ, 0);
   
    br2.setQuery(geoQ);
    doTest(br2,2,null,new String[]{"1","5"});

    expl = b.explain(geoQ, 1);
     
      // facet query for color "red" and getting facet counts for the distance facet.
    BrowseRequest br3 = new BrowseRequest();
    br3.setCount(10);
    br3.setOffset(0)

    BrowseSelection sel3 = new BrowseSelection("color");
    sel3.addValue("red");
    HashMap<String, Float> map3 = new HashMap<String, Float>();
    map3.put("red", 3.0f);
    FacetTermQuery colorQ = new FacetTermQuery(sel3,map3);

    BoboBrowser b2 = newBrowser();
    Explanation expl2 = b.explain(colorQ, 0);

    br3.setFacetSpec("correctDistance", geoSpec);
    geoSpec.setMinHitCount(1);
    br3.setQuery(colorQ);             // query is color=red
    br3.addSelection(sel);        // count facets <30,70,5> and <60,120,1>
    answer.clear();
    answer.put("correctDistance", Arrays.asList(new BrowseFacet[]{new BrowseFacet("60,120:1",1)}));   
    doTest(br3, 1 , answer, null);
  }
View Full Code Here

    pathSpec.setOrderBy(FacetSortSpec.OrderHitsDesc);
    br.setFacetSpec("multipath", pathSpec);
   
    HashMap<String,List<BrowseFacet>> answer=new HashMap<String,List<BrowseFacet>>();
    answer=new HashMap<String,List<BrowseFacet>>();
    answer.put("multipath", Arrays.asList(new BrowseFacet[]{new BrowseFacet("a-b",7),new BrowseFacet("a-c",4),new BrowseFacet("a-e",2)}));
    doTest(br,7,answer,null);
  }
View Full Code Here

    pathSpec.setOrderBy(FacetSortSpec.OrderHitsDesc);
    br.setFacetSpec("path", pathSpec);
   
    HashMap<String,List<BrowseFacet>> answer=new HashMap<String,List<BrowseFacet>>();
    answer=new HashMap<String,List<BrowseFacet>>();
    answer.put("path", Arrays.asList(new BrowseFacet[]{new BrowseFacet("a-c-d",2),new BrowseFacet("a-e-f",1)}));
    doTest(br,3,answer,null);
   
    pathSpec.setOrderBy(FacetSortSpec.OrderByCustom);
    pathSpec.setCustomComparatorFactory(new ComparatorFactory(){

      public IntComparator newComparator(
          FieldValueAccessor fieldValueAccessor, final int[] counts) {
        return new IntComparator(){

          public int compare(Integer f1, Integer f2) {
            int val = counts[f2] - counts[f1];
            if (val==0)
                {
                    val=f2-f1;
                }
                return val;
          }
         
          public int compare(int f1, int f2) {
            int val = counts[f2] - counts[f1];
            if (val==0)
            {
              val=f2-f1;
            }
            return val;
          }
         
        };
      }

      public Comparator<BrowseFacet> newComparator() {
        return new Comparator<BrowseFacet>(){
          public int compare(BrowseFacet f1, BrowseFacet f2) {
            int val = f2.getHitCount() - f1.getHitCount();
            if (val==0)
                {
                    val=f1.getValue().compareTo(f2.getValue());
                }
                return val;
         
        };
      }
     
    });
   
    answer=new HashMap<String,List<BrowseFacet>>();
    answer.put("path", Arrays.asList(new BrowseFacet[]{new BrowseFacet("a-c-d",2),new BrowseFacet("a-e-f",1)}));
    doTest(br,3,answer,null);
  }
View Full Code Here

    tagOutput.setOrderBy(FacetSortSpec.OrderHitsDesc);
   
    br.setFacetSpec("tag", tagOutput);
   
    HashMap<String,List<BrowseFacet>> answer=new HashMap<String,List<BrowseFacet>>();
    answer.put("location", Arrays.asList(new BrowseFacet[]{new BrowseFacet("toy/lego/block",3)}));
    answer.put("tag", Arrays.asList(new BrowseFacet[]{new BrowseFacet("pet",2),new BrowseFacet("animal",1),new BrowseFacet("dog",1),new BrowseFacet("funny",1),new BrowseFacet("humor",1),new BrowseFacet("joke",1),new BrowseFacet("poodle",1),new BrowseFacet("rabbit",1)}));
    doTest(br,3,answer,null);
  }
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.