Package com.browseengine.bobo.api

Examples of com.browseengine.bobo.api.BrowseRequest


       
  }
 
  public void testMissedSelection()
  {
    BrowseRequest br=new BrowseRequest();
    br.setCount(10);
    br.setOffset(0);
    BrowseSelection sel=new BrowseSelection("location");
    sel.addValue("something/stupid");
    br.addSelection(sel);
    doTest(br,0,null,null);
  }
View Full Code Here


    br.addSelection(sel);
    doTest(br,0,null,null);
  }
 
  public void testDateRange() {
    BrowseRequest br=new BrowseRequest();
    br.setCount(10);
    br.setOffset(0);
   
    FacetSpec simpleOutput=new FacetSpec();
    simpleOutput.setExpandSelection(true);
    br.setFacetSpec("date", simpleOutput);
   
    HashMap<String,List<BrowseFacet>> answer=new HashMap<String,List<BrowseFacet>>();
    answer.put("date",  Arrays.asList(new BrowseFacet[]{new BrowseFacet("[2000/01/01 TO 2003/05/05]", 4), new BrowseFacet("[2003/05/06 TO 2005/04/04]",1)}));
    doTest(br,7,answer,null);
  }
View Full Code Here

 
  /**
   * Verifies the range facet numbers are returned correctly (as they were passed in)
   */
  public void testNumEndorsers() {
    BrowseRequest br=new BrowseRequest();
    br.setCount(10);
    br.setOffset(0);
   
    FacetSpec simpleOutput=new FacetSpec();
    simpleOutput.setExpandSelection(true);
    br.setFacetSpec("numendorsers", simpleOutput);
   
    HashMap<String,List<BrowseFacet>> answer=new HashMap<String,List<BrowseFacet>>();
    answer.put("numendorsers",  Arrays.asList(new BrowseFacet[]{new BrowseFacet("[000000 TO 000005]", 2), new BrowseFacet("[000006 TO 000010]",2), new BrowseFacet("[000011 TO 000020]",3)}));
    doTest(br,7,answer,null);
  }
View Full Code Here

    answer.put("numendorsers",  Arrays.asList(new BrowseFacet[]{new BrowseFacet("[000000 TO 000005]", 2), new BrowseFacet("[000006 TO 000010]",2), new BrowseFacet("[000011 TO 000020]",3)}));
    doTest(br,7,answer,null);
  }
 
  public void testBrowse(){
    BrowseRequest br=new BrowseRequest();
    br.setCount(10);
    br.setOffset(0);
   
    BrowseSelection sel=new BrowseSelection("color");
    sel.addValue("red");
    br.addSelection(sel);
   
    sel=new BrowseSelection("location");
    sel.addValue("toy/lego");
   
    Properties prop = sel.getSelectionProperties();
    PathFacetHandler.setDepth(prop, 1);
    br.addSelection(sel);
   
    sel=new BrowseSelection("size");
    sel.addValue("[* TO 4]");
   
      sel=new BrowseSelection("tag");
    sel.addValue("rabbit");
    br.addSelection(sel);
   
    FacetSpec output=new FacetSpec();
    output.setMaxCount(5);
   
    FacetSpec simpleOutput=new FacetSpec();
    simpleOutput.setExpandSelection(true);
   
   
    br.setFacetSpec("color", simpleOutput);
    br.setFacetSpec("size", output);
    br.setFacetSpec("shape", simpleOutput);
    br.setFacetSpec("location", output);
   
    FacetSpec tagOutput=new FacetSpec();
    tagOutput.setMaxCount(5);
    tagOutput.setOrderBy(FacetSortSpec.OrderHitsDesc);
   
    br.setFacetSpec("tag", tagOutput);
   
    HashMap<String,List<BrowseFacet>> answer=new HashMap<String,List<BrowseFacet>>();
    answer.put("color",  Arrays.asList(new BrowseFacet[]{new BrowseFacet("green",1),new BrowseFacet("red",2)}));
    answer.put("size", Arrays.asList(new BrowseFacet[]{new BrowseFacet("[* TO 4]",1),new BrowseFacet("[5 TO 8]",1)}));
    answer.put("shape", Arrays.asList(new BrowseFacet[]{new BrowseFacet("square",2)}));
View Full Code Here

   * submitting the same browserequest 2 times generating 2 BrowseResults. 
   * The 2 BoboBrowsers are instantiated with the MultiBoboBrowser and the browse method is called.
   * The BrowseResult generated is submitted to the doTest method which compares the result
   */
  public void testMultiBrowser() throws Exception {
    BrowseRequest browseRequest = new BrowseRequest();
      browseRequest.setCount(10);
      browseRequest.setOffset(0);
      browseRequest.addSortField(new SortField("date",SortField.CUSTOM));
     
      BrowseSelection colorSel = new BrowseSelection("color");
      colorSel.addValue("red");
      browseRequest.addSelection(colorSel);
     
      BrowseSelection tageSel = new BrowseSelection("tag");
      tageSel.addValue("rabbit");
      browseRequest.addSelection(tageSel);
     
      FacetSpec colorFacetSpec = new FacetSpec();
      colorFacetSpec.setExpandSelection(true);
      colorFacetSpec.setOrderBy(FacetSortSpec.OrderHitsDesc);
     
      FacetSpec tagFacetSpec = new FacetSpec();
             
      browseRequest.setFacetSpec("color", colorFacetSpec);
      browseRequest.setFacetSpec("tag", tagFacetSpec);
     
      FacetSpec shapeSpec = new FacetSpec();
      shapeSpec.setOrderBy(FacetSortSpec.OrderHitsDesc);
      browseRequest.setFacetSpec("shape", shapeSpec);
     
      FacetSpec dateSpec=new FacetSpec();
      dateSpec.setExpandSelection(true);
      browseRequest.setFacetSpec("date", dateSpec);
     
      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

   
    BooleanQuery bq = new BooleanQuery();
    bq.add(shapeQ,Occur.SHOULD);
    bq.add(colorQ,Occur.SHOULD);
   
    BrowseRequest br = new BrowseRequest();
    br.setSort(new SortField[]{SortField.FIELD_SCORE});
    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
View Full Code Here

    map2.put("rabbit", 100.0f);
    map2.put("dog", 50.0f);
    FacetTermQuery tagQ = new FacetTermQuery(sel2,map2);
   
   
    BrowseRequest br = new BrowseRequest();
    br.setQuery(colorQ);
    br.setOffset(0);
    br.setCount(10);
   
    doTest(br,5,null,new String[]{"1","2","7","4","5"});
   
    //BoboBrowser b = newBrowser();
  //  Explanation expl = b.explain(colorQ, 0);
   
    br.setQuery(tagQ);
    doTest(br,4,null,new String[]{"7","1","3","2"});
  //  expl = b.explain(tagQ, 6);
   
  }
View Full Code Here

      map2.put("rabbit", 100.0f);
      map2.put("dog", 50.0f);
      FacetTermQuery tagQ = new FacetTermQuery(sel2,map2);
     
     
      BrowseRequest br = new BrowseRequest();

      br.setOffset(0);
      br.setCount(10);
     
     
      BooleanQuery bq = new BooleanQuery(true);
      bq.add(colorQ, Occur.SHOULD);
      bq.add(tagQ, Occur.SHOULD);
     
      br.setQuery(bq);
      doTest(br, 6, null, new String[]{"7","1","3","2","4","5"});
     
     
    }
View Full Code Here

    HashMap<String, Float> map = new HashMap<String, Float>();
    map.put("000002", 100.0f);
    map.put("000010", 50.0f);
    FacetTermQuery numberQ = new FacetTermQuery(sel,map);
   
    BrowseRequest br = new BrowseRequest();
    br.setQuery(numberQ);
    br.setOffset(0);
    br.setCount(10);
   
    doTest(br,4,null,new String[]{"5","2","1","6"});
  }
View Full Code Here

    map.put("dog", 7.0f);
      boostMaps.put("tag", map);
     
      Query q = new ScoreAdjusterQuery(new MatchAllDocsQuery(), new FacetBasedBoostScorerBuilder(boostMaps));
     
      BrowseRequest br = new BrowseRequest();
      br.setQuery(q);
    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"});
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.