Package com.browseengine.bobo.api

Examples of com.browseengine.bobo.api.FacetSpec


  public void clearSelection(String name){
    _req.removeSelection(name);
  }
 
  public void applyFacetSpec(String name,int minHitCount,int maxCount,boolean expand,FacetSortSpec orderBy){
    FacetSpec fspec = new FacetSpec();
    fspec.setMinHitCount(minHitCount);
    fspec.setMaxCount(maxCount);
    fspec.setExpandSelection(expand);
    fspec.setOrderBy(orderBy);
    _req.setFacetSpec(name, fspec);
  }
View Full Code Here


     breq.setSort(sortFields);
    }
   
    List<BrowseRequestBPO.FacetSpec> fspecList = req.getFacetSpecsList();
    for (BrowseRequestBPO.FacetSpec fspec : fspecList){
      FacetSpec facetSpec = new FacetSpec();
      facetSpec.setExpandSelection(fspec.getExpand());
      facetSpec.setMaxCount(fspec.getMax());
      facetSpec.setMinHitCount(fspec.getMinCount());
      BrowseRequestBPO.FacetSpec.SortSpec fsort = fspec.getOrderBy();
      if (fsort == BrowseRequestBPO.FacetSpec.SortSpec.HitsDesc)
      {
        facetSpec.setOrderBy(FacetSortSpec.OrderHitsDesc);
      }
      else
      {
        facetSpec.setOrderBy(FacetSortSpec.OrderValueAsc)
      }
      breq.setFacetSpec(fspec.getName(), facetSpec);
    }
   
    List<BrowseRequestBPO.Selection> selList = req.getSelectionsList();
View Full Code Here

    // facetspec
    Map<String,FacetSpec> facetSpecMap = req.getFacetSpecs();
    Iterator<Entry<String,FacetSpec>> iter = facetSpecMap.entrySet().iterator();
    while(iter.hasNext()){
      Entry<String,FacetSpec> entry = iter.next();
      FacetSpec fspec = entry.getValue();
      if (fspec!=null)
      {
        BrowseRequestBPO.FacetSpec.Builder facetspecBuilder = BrowseRequestBPO.FacetSpec.newBuilder();
        facetspecBuilder.setName(entry.getKey());
        facetspecBuilder.setExpand(fspec.isExpandSelection());
        facetspecBuilder.setMax(fspec.getMaxCount());
        facetspecBuilder.setMinCount(fspec.getMinHitCount());
        if (fspec.getOrderBy() == FacetSortSpec.OrderHitsDesc){
          facetspecBuilder.setOrderBy(BrowseRequestBPO.FacetSpec.SortSpec.HitsDesc);
        }
        else{
          facetspecBuilder.setOrderBy(BrowseRequestBPO.FacetSpec.SortSpec.ValueAsc);
        }
View Full Code Here

    if (_count > 0) {
      if (_groupBy == null) {
        resList = ListMerger.mergeLists(_offset, _count, iterList, MERGE_COMPATATOR);
      }
      else {
        _groupAccessible = new CombinedFacetAccessible(new FacetSpec(), _facetAccessibles);
        resList = new ArrayList<MyScoreDoc>(_count);
        Iterator<MyScoreDoc> mergedIter = ListMerger.mergeLists(iterList, MERGE_COMPATATOR);
        Set<Object> groupSet = new HashSet<Object>(_offset+_count);
        int offsetLeft = _offset;
        while(mergedIter.hasNext())
View Full Code Here

    }
    sel.setSelectionProperties(selectionProperties);
    sel.setSelectionOperation(operation);
    req.addSelection(sel);
    req.setCount(50);
    FacetSpec fs = new FacetSpec();
    fs.setMinHitCount(minHitCount);
    req.setFacetSpec(AttributeHandlerName, fs);
    return req;
  }
View Full Code Here

        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());
View Full Code Here

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

    FacetSpec output = new FacetSpec();
    output.setMaxCount(100);
    output.setMinHitCount(1);
    br.setFacetSpec("numberhisto", output);

    BrowseFacet[] answerBucketFacets = new BrowseFacet[5];
    answerBucketFacets[0] = new BrowseFacet("0000000000", 3);
    answerBucketFacets[1] = new BrowseFacet("0000000002", 1);
View Full Code Here

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

    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);
View Full Code Here

    BrowseSelection sel = new BrowseSelection("groups");
    sel.addValue("g2");
    br.addSelection(sel);

    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);
View Full Code Here

    BrowseSelection sel = new BrowseSelection("virtual");
    sel.addValue("10");
    sel.addValue("11");
    br.addSelection(sel);

    FacetSpec spec = new FacetSpec();
    spec.setOrderBy(FacetSortSpec.OrderValueAsc);
    br.setFacetSpec("virtual", spec);

    HashMap<String, List<BrowseFacet>> answer = new HashMap<String, List<BrowseFacet>>();
    answer.put("virtual",
      Arrays.asList(new BrowseFacet[] { new BrowseFacet("0010", 1), new BrowseFacet("0011", 1) }));
View Full Code Here

TOP

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

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.