Package com.browseengine.bobo.api

Examples of com.browseengine.bobo.api.BrowseRequest


   
  }
 
  public void testExpandSelection()
  {
    BrowseRequest br=new BrowseRequest();
    br.setCount(10);
    br.setOffset(0);

        BrowseSelection sel=new BrowseSelection("color");
        sel.addValue("red");
        br.addSelection(sel);

    FacetSpec output=new FacetSpec();
    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)}));
   
View Full Code Here


   
    doTest(br,2,answer,new String[]{"1","7"});
  }
 
  public void testPath() throws Exception{
    BrowseRequest br=new BrowseRequest();
    br.setCount(10);
    br.setOffset(0);

        BrowseSelection sel=new BrowseSelection("path");
        sel.addValue("a");
        Properties prop = sel.getSelectionProperties();
        PathFacetHandler.setDepth(prop, 1);
        br.addSelection(sel);
   
    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);
   
View Full Code Here

    doTest(br,7,answer,null);
  }
 
  public void testComboFacetHandlerSelectionOnly(){
   
    BrowseRequest br=new BrowseRequest();
    br.setCount(10);
    br.setOffset(0);
   
    BrowseSelection sel=new BrowseSelection("colorShape");
    sel.addValue("color:green");
    sel.addValue("shape:rectangle");
    sel.addValue("shape:square");
    sel.setSelectionOperation(ValueOperation.ValueOperationOr);
    br.addSelection(sel);
   
    doTest(br,6,null,new String[]{"1","2","3","5","6","7"});
   
    br=new BrowseRequest();
    br.setCount(10);
    br.setOffset(0);
   
    sel=new BrowseSelection("colorShape");
    sel.addValue("color:green");
    sel.addValue("shape:rectangle");
    sel.setSelectionOperation(ValueOperation.ValueOperationAnd);
    br.addSelection(sel);
   
    doTest(br,1,null,new String[]{"6"});
   
    br=new BrowseRequest();
    br.setCount(10);
    br.setOffset(0);
   
    sel=new BrowseSelection("colorShapeMultinum");
    sel.addValue("color:red");
    sel.addValue("shape:square");
    sel.setSelectionOperation(ValueOperation.ValueOperationOr);
    sel.addNotValue("multinum:001");
    sel.addNotValue("multinum:003");
    br.addSelection(sel);
   
    doTest(br,1,null,new String[]{"2"});
   
    br=new BrowseRequest();
    br.setCount(10);
    br.setOffset(0);
   
    sel=new BrowseSelection("colorShapeMultinum");
    sel.addValue("color:red");
    sel.addValue("shape:square");
    sel.setSelectionOperation(ValueOperation.ValueOperationOr);
    sel.addNotValue("multinum:003");
    br.addSelection(sel);
   
    doTest(br,2,null,new String[]{"2","5"});
   
   
  }
View Full Code Here

   * This tests GeoSimpleFacetHandler
   * @throws Exception
   */
  public void testSimpleGeo() throws Exception{
    // testing facet counts for two distance facets - <30,70,5>, <60,120,1>
    BrowseRequest br=new BrowseRequest();
    br.setCount(10);
    br.setOffset(0);

        BrowseSelection sel=new BrowseSelection("distance");
        sel.addValue("30,70:5");
        sel.addValue("60,120:1");
        br.addSelection(sel);
   
    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

   * This tests GeoFacetHandler
   * @throws Exception
   */
  public void testGeo() throws Exception{
    // testing facet counts for two distance facets - <30,70,5>, <60,120,1>
    BrowseRequest br=new BrowseRequest();
    br.setCount(10);
    br.setOffset(0);

        BrowseSelection sel=new BrowseSelection("correctDistance");
        sel.addValue("30,75:100");
        sel.addValue("60,120:1");
        br.addSelection(sel);
   
    FacetSpec geoSpec=new FacetSpec();
    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

    answer.put("correctDistance", Arrays.asList(new BrowseFacet[]{new BrowseFacet("60,120:1",1)}));   
    doTest(br3, 1 , answer, null);
  }

  public void testMultiPath() throws Exception{
    BrowseRequest br=new BrowseRequest();
    br.setCount(10);
    br.setOffset(0);

        BrowseSelection sel=new BrowseSelection("multipath");
        sel.addValue("a");
        Properties prop = sel.getSelectionProperties();
        PathFacetHandler.setDepth(prop, 1);
        br.addSelection(sel);
   
    FacetSpec pathSpec=new FacetSpec();
    pathSpec.setMaxCount(3);
   
    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

    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);
  }
 
  public void testMultiSelectedPaths() throws Exception{
    BrowseRequest br=new BrowseRequest();
    br.setCount(10);
    br.setOffset(0);

        BrowseSelection sel=new BrowseSelection("path");
        sel.addValue("a-c");
        sel.addValue("a-e");
        Properties prop = sel.getSelectionProperties();
        PathFacetHandler.setDepth(prop, 1);
        PathFacetHandler.setStrict(prop, true);
        br.addSelection(sel);
   
    FacetSpec pathSpec=new FacetSpec();
    pathSpec.setMaxCount(3);
   
    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);
View Full Code Here

    answer.put("path", Arrays.asList(new BrowseFacet[]{new BrowseFacet("a-c-d",2),new BrowseFacet("a-e-f",1)}));
    doTest(br,3,answer,null);
  }
 
  public void testTagRollup(){
    BrowseRequest br=new BrowseRequest();
    br.setCount(10);
    br.setOffset(0);

        BrowseSelection sel=new BrowseSelection("location");
        Properties prop = sel.getSelectionProperties();
        PathFacetHandler.setDepth(prop, 1);
        PathFacetHandler.setStrict(prop, true);
        sel.addValue("toy/lego");
        br.addSelection(sel);
   
    FacetSpec locationOutput=new FacetSpec();
   
    br.setFacetSpec("location", locationOutput);
   
    FacetSpec tagOutput=new FacetSpec();
    tagOutput.setMaxCount(50);
    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

    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);
  }
 
  public void testChar(){
    BrowseRequest br=new BrowseRequest();
      br.setCount(10);
      br.setOffset(0);
     
      BrowseSelection sel=new BrowseSelection("char");
      sel.addValue("j");
      br.addSelection(sel);
      doTest(br,1,null,new String[]{"3"});
     
      br=new BrowseRequest();
      br.setCount(10);
      br.setOffset(0);
     
      sel=new BrowseSelection("color");
      sel.addValue("red");
      br.addSelection(sel);
     
      FacetSpec charOutput=new FacetSpec();
      charOutput.setMaxCount(50);
      charOutput.setOrderBy(FacetSortSpec.OrderHitsDesc);
     

      br.setFacetSpec("char", charOutput);
      br.addSortField(new SortField("date",SortField.CUSTOM,true));
     
      HashMap<String,List<BrowseFacet>> answer=new HashMap<String,List<BrowseFacet>>();
      answer.put("char", Arrays.asList(new BrowseFacet[]{new BrowseFacet("a",1),new BrowseFacet("i",1),new BrowseFacet("k",1)}));
     
      doTest(br,3,answer,new String[]{"7","2","1"});
View Full Code Here

     
      doTest(br,3,answer,new String[]{"7","2","1"});
  }
 
  public void testDate(){
    BrowseRequest br=new BrowseRequest();
      br.setCount(10);
      br.setOffset(0);
     
      BrowseSelection sel=new BrowseSelection("date");
      sel.addValue("[2001/01/01 TO 2005/01/01]");
      br.addSelection(sel);
     
      FacetSpec ospec=new FacetSpec();
      ospec.setExpandSelection(false);
      br.setFacetSpec("color", ospec);
    
      br.addSortField(new SortField("date",SortField.CUSTOM,true));
     
      HashMap<String,List<BrowseFacet>> answer=new HashMap<String,List<BrowseFacet>>();
      answer.put("color", Arrays.asList(new BrowseFacet[]{new BrowseFacet("blue",2),new BrowseFacet("green",1),new BrowseFacet("red",1)}));
      doTest(br,4,answer,new String[]{"4","2","5","3"});
  }
View Full Code Here

TOP

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

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.