Package com.browseengine.bobo.api

Examples of com.browseengine.bobo.api.BrowseRequest


    long hitscount = 0;
    for(int x=0; x< inNumItr; x++)
    {
      long t0 = System.currentTimeMillis();
      BoboBrowser browser = new BoboBrowser(boboReader);
      BrowseRequest req = new BrowseRequest();
      req.setCount(500);
      FacetSpec spec = new FacetSpec();
      spec.setMaxCount(50);
      spec.setOrderBy(FacetSortSpec.OrderHitsDesc);
//      req.setFacetSpec("ccid", spec);
//      req.setFacetSpec("pcid", spec);
//      req.setFacetSpec("education_id", spec);
      req.setFacetSpec("geo_region", spec);
//      req.setFacetSpec("industry", spec);
      String qstr = words[nextInt()];
//      qstr = "project manager";
      String[] terms = qstr.split(" ");
      BooleanQuery q = new BooleanQuery();
    for(String s : terms)
    {
      q.add( new TermQuery(new Term("b",s)), Occur.MUST);
    }
//      q.add(new MatchAllDocsQuery(), Occur.MUST);
      req.setQuery(q);//new TermQuery(new Term("b",qstr)));
      BrowseSelection sel = new BrowseSelection("ccid");
      sel.addValue("0000001384");
//      req.addSelection(sel );
      BrowseSelection seli = new BrowseSelection("industry");
      seli.addValue("0000000052");
View Full Code Here


      len = r.length;
    }
   
    public synchronized BrowseRequest next() {
      if (idx<len){
        BrowseRequest br = req[idx];
        idx++;
        return br;
      }
      else{
        return null;
View Full Code Here

      doTest(br,7,answer,new String[]{"7","1","2"});
  }
 
 
  public void testMinHit(){
    BrowseRequest br=new BrowseRequest();
      br.setCount(3);
      br.setOffset(0);
     
      BrowseSelection sel = new BrowseSelection("shape");
      sel.addValue("square");
      br.addSelection(sel);
       
      FacetSpec spec = new FacetSpec();
      spec.setMinHitCount(0);
      spec.setOrderBy(FacetSortSpec.OrderHitsDesc);
      br.setFacetSpec("color", spec);
               
      HashMap<String,List<BrowseFacet>> answer=new HashMap<String,List<BrowseFacet>>();
      answer.put("color", Arrays.asList(new BrowseFacet[]{new BrowseFacet("red",2),new BrowseFacet("blue",1),new BrowseFacet("green",0)}));
       
      doTest(br,3,answer,null);
View Full Code Here

      doTest(br,3,answer,null);
  }
 
  public void testRandomAccessFacet() throws Exception
  {
    BrowseRequest br=new BrowseRequest();
      br.setCount(10);
      br.setOffset(0);
      br.setFacetSpec("number",new FacetSpec());
     
      BoboBrowser browser = newBrowser();
     
      BrowseResult res=browser.browse(br);
      FacetAccessible facetAccessor = res.getFacetAccessor("number");
View Full Code Here

      assertEquals(facet.getFacetValueHitCount(), 1);
      res.close();
  }
 
  public void testQueryWithScore() throws Exception{
    BrowseRequest br=new BrowseRequest();
    br.setShowExplanation(false)// default
      QueryParser parser=new QueryParser(Version.LUCENE_29,"color",new StandardAnalyzer(Version.LUCENE_29));
      br.setQuery(parser.parse("color:red OR shape:square"));
        br.setCount(10);
        br.setOffset(0);
       
        br.setSort(new SortField[]{SortField.FIELD_SCORE});
        BrowseResult res = doTest(br,4,null,new String[]{"1","7","2","5"});
       
        BrowseHit[] hits = res.getHits();
        for (BrowseHit hit : hits){
          assertNull(hit.getExplanation());
        }
       
        br.setShowExplanation(true);
        res = doTest(br,4,null,new String[]{"1","7","2","5"});
        hits = res.getHits();
        for (BrowseHit hit : hits){
          assertNotNull(hit.getExplanation());
        }
       
        Query rawQuery = br.getQuery();
       
          SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd");
        Date d = format.parse("2006/06/01");
        long fromTime = d.getTime();
       
        RecencyBoostScorerBuilder recencyBuilder = new RecencyBoostScorerBuilder("date", 2.0f, TimeUnit.DAYS.convert(fromTime,TimeUnit.MILLISECONDS), 30L, TimeUnit.DAYS);
        ScoreAdjusterQuery sq = new ScoreAdjusterQuery(rawQuery,recencyBuilder);
        br.setQuery(sq);
       
          res = doTest(br,4,null,new String[]{"7","1","2","5"});
       
        hits = res.getHits();
        for (BrowseHit hit : hits){
View Full Code Here

       
  }

  public void testBrowseWithQuery(){
    try{
      BrowseRequest br=new BrowseRequest();
      QueryParser parser=new QueryParser(Version.LUCENE_29,"shape",new StandardAnalyzer(Version.LUCENE_29));
      br.setQuery(parser.parse("square OR circle"));
        br.setCount(10);
        br.setOffset(0);
       
        BrowseSelection sel=new BrowseSelection("color");
        sel.addValue("red");
        br.addSelection(sel);
       
       
        br.setSort(new SortField[]{new SortField("number",SortField.CUSTOM,false)});
        doTest(br,2,null,new String[]{"7","1"});
       

        FacetSpec ospec=new FacetSpec();
        ospec.setExpandSelection(true);
        br.setFacetSpec("color", ospec);
        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",2)}));
        doTest(br,2,answer,new String[]{"7","1"});
       
        br.clearSelections();
        answer.put("color", Arrays.asList(new BrowseFacet[]{new BrowseFacet("blue",2),new BrowseFacet("green",1),new BrowseFacet("red",2)}));
        doTest(br,5,answer,new String[]{"7","1","3","4","5"});
       
    }
    catch(Exception e)
View Full Code Here

      fail(e.getMessage());
    }
  }
 
  public void testBrowseCompactMultiVal(){
    BrowseRequest br=new BrowseRequest();
    br.setCount(10);
      br.setOffset(0);
      BrowseSelection sel=new BrowseSelection("compactnum");
      sel.addValue("001");
      sel.addValue("003");
      sel.addValue("007");
      br.addSelection(sel);
     
      FacetSpec ospec=new FacetSpec();
      br.setFacetSpec("compactnum", ospec);
     
      br.setSort(new SortField[]{new SortField("compactnum",SortField.CUSTOM,true)});
     
      HashMap<String,List<BrowseFacet>> answer=new HashMap<String,List<BrowseFacet>>();
      
      answer.put("compactnum", Arrays.asList(new BrowseFacet[]{new BrowseFacet("001",3),new BrowseFacet("002",1),new BrowseFacet("003",3),new BrowseFacet("007",2),new BrowseFacet("008",1),new BrowseFacet("012",1)}));
       
      doTest(br,6,answer,new String[]{"3","7","4","6","1","5"});
     
     
      br=new BrowseRequest();
    br.setCount(10);
      br.setOffset(0);
      sel=new BrowseSelection("compactnum");
      sel.addValue("001");
      sel.addValue("002");
      sel.addValue("003");
      br.addSelection(sel);
      sel.setSelectionOperation(ValueOperation.ValueOperationAnd);
      doTest(br,1,null,new String[]{"6"});
     
      br=new BrowseRequest();
    br.setCount(10);
      br.setOffset(0);
      sel=new BrowseSelection("compactnum");
      sel.addValue("001");
      sel.addValue("003");
      sel.addValue("008");
      sel.setSelectionOperation(ValueOperation.ValueOperationOr);
      br.addSelection(sel);
     
      sel=new BrowseSelection("color");
      sel.addValue("red");
      br.addSelection(sel);
     
      ospec=new FacetSpec();
      br.setFacetSpec("color", ospec);
     
      ospec=new FacetSpec();
      br.setFacetSpec("compactnum",ospec);
      answer=new HashMap<String,List<BrowseFacet>>();
          
          answer.put("compactnum", Arrays.asList(new BrowseFacet[]{new BrowseFacet("001",1),new BrowseFacet("003",2),new BrowseFacet("008",1)}));
          answer.put("color", Arrays.asList(new BrowseFacet[]{new BrowseFacet("red",2)}));
          doTest(br,2,answer,new String[]{"1","7"});
View Full Code Here

         
      doTest(br,2,answer,new String[]{"1","7"});
  }
 
  public void testBrowseMultiVal(){
    BrowseRequest br=new BrowseRequest();
    br.setCount(10);
      br.setOffset(0);
      BrowseSelection sel=new BrowseSelection("multinum");
      sel.addValue("001");
      sel.addValue("003");
      sel.addValue("007");
      br.addSelection(sel);
     

      FacetSpec ospec=new FacetSpec();
      br.setFacetSpec("multinum", ospec);
      br.setSort(new SortField[]{new SortField("multinum",SortField.CUSTOM,true)});
      HashMap<String,List<BrowseFacet>> answer=new HashMap<String,List<BrowseFacet>>();

    answer.put("multinum", Arrays.asList(new BrowseFacet[]{new BrowseFacet("001",3),new BrowseFacet("002",1),new BrowseFacet("003",3),new BrowseFacet("007",2),new BrowseFacet("008",1),new BrowseFacet("012",1)}));
     
      doTest(br,6,answer,new String[]{"3","4","7","1","6","5"});
     
     
   
    br=new BrowseRequest();
    br.setCount(10);
      br.setOffset(0);
      sel=new BrowseSelection("multinum");
      sel.addValue("001");
      sel.addValue("002");
      sel.addValue("003");
      br.addSelection(sel);
      sel.setSelectionOperation(ValueOperation.ValueOperationAnd);
      doTest(br,1,null,new String[]{"6"});
     
      br=new BrowseRequest();
    br.setCount(10);
      br.setOffset(0);
      sel=new BrowseSelection("multinum");
      sel.addValue("001");
      sel.addValue("003");
      sel.addValue("008");
      sel.setSelectionOperation(ValueOperation.ValueOperationOr);
      br.addSelection(sel);
     
      sel=new BrowseSelection("color");
      sel.addValue("red");
      br.addSelection(sel);
     
      ospec=new FacetSpec();
      br.setFacetSpec("color", ospec);
           
      ospec=new FacetSpec();
      br.setFacetSpec("multinum",ospec);
      answer=new HashMap<String,List<BrowseFacet>>();
      
      answer.put("multinum", Arrays.asList(new BrowseFacet[]{new BrowseFacet("001",1),new BrowseFacet("003",2),new BrowseFacet("008",1)}));
      answer.put("color", Arrays.asList(new BrowseFacet[]{new BrowseFacet("red",2)}));
      doTest(br,2,answer,new String[]{"1","7"});
View Full Code Here

  public void testBrowseWithDeletes()
  {
    BoboIndexReader reader = null;

    BrowseRequest br = new BrowseRequest();
    br.setCount(10);
    br.setOffset(0);

    BrowseSelection sel = new BrowseSelection("color");
    sel.addValue("red");
    br.addSelection(sel);
    HashMap<String, List<BrowseFacet>> answer = new HashMap<String, List<BrowseFacet>>();

    doTest(br, 3, answer, new String[] {"1", "2", "7"});

    try
    {
      reader = newIndexReader(false);
      reader.deleteDocuments(new Term("id", "1"));
      reader.deleteDocuments(new Term("id", "2"));
     
      br = new BrowseRequest();
      br.setCount(10);
      br.setOffset(0);

      sel = new BrowseSelection("color");
      sel.addValue("red");
      br.addSelection(sel);
      answer = new HashMap<String, List<BrowseFacet>>();

      doTest(new BoboBrowser(reader), br, 1, answer, null);
    }
    catch (IOException ioe)
    {
      fail(ioe.getMessage());
    }
    finally
    {
      if (reader != null)
      {
        try
        {
          reader.close();
        }
        catch (IOException e)
        {
          fail(e.getMessage());
        }
      }
    }
   
    br = new BrowseRequest();
    br.setCount(10);
    br.setOffset(0);

    sel = new BrowseSelection("color");
    sel.addValue("red");
    br.addSelection(sel);
    answer = new HashMap<String, List<BrowseFacet>>();


    doTest(br, 1, answer, null);
  }
View Full Code Here

  }

 
  public void testNotSupport()
  {
    BrowseRequest br=new BrowseRequest();
    br.setCount(10);
    br.setOffset(0);
   
    BrowseSelection sel=new BrowseSelection("color");
    sel.addNotValue("red");
    br.addSelection(sel);
   
    FacetSpec simpleOutput=new FacetSpec();
    br.setFacetSpec("shape", simpleOutput);
   
    HashMap<String,List<BrowseFacet>> answer=new HashMap<String,List<BrowseFacet>>();
    answer.put("shape", Arrays.asList(new BrowseFacet[]{new BrowseFacet("circle",2),new BrowseFacet("rectangle",1),new BrowseFacet("square",1)}));

    doTest(br,4,answer,new String[]{"3","4","5","6"});
   
    sel.addNotValue("green");
   
    answer.put("shape", Arrays.asList(new BrowseFacet[]{new BrowseFacet("circle",1),new BrowseFacet("square",1)}));

        doTest(br,2,answer,new String[]{"4","5"});
   
        br=new BrowseRequest();
        br.setCount(10);
        br.setOffset(0);
        sel=new BrowseSelection("compactnum");
        sel.addNotValue("3");
        sel.addNotValue("4");
        sel.addValue("1");
        sel.addValue("2");
        sel.addValue("7");
       
        br.addSelection(sel);
        doTest(br,3,null,new String[]{"3","4","5"});
       
        br=new BrowseRequest();
        br.setCount(10);
        br.setOffset(0);
        sel=new BrowseSelection("multinum");
        sel.addNotValue("3");
        sel.addNotValue("4");
        sel.addValue("1");
        sel.addValue("2");
        sel.addValue("7");
       
        br.addSelection(sel);
       
        doTest(br,3,null,new String[]{"3","4","5"});
       
       
  }
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.