Package com.browseengine.bobo.api

Examples of com.browseengine.bobo.api.BrowseFacet


    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


    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

    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, new String[] { "1", "3", "4", "5" });
    // 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);

    br2.setQuery(geoQ);
    doTest(br2, 2, null, new String[] { "1", "5" });

    // 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);

    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

    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);

    br2.setQuery(geoQ);
    doTest(br2, 2, null, new String[] { "1", "5" });

    // 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);

    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

    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

    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() {

      @Override
      public IntComparator newComparator(FieldValueAccessor fieldValueAccessor,
          final BigSegmentedArray counts) {
        return new IntComparator() {

          @Override
          public int compare(Integer f1, Integer f2) {
            int val = counts.get(f2) - counts.get(f1);
            if (val == 0) {
              val = f2 - f1;
            }
            return val;
          }

          @Override
          public int compare(int f1, int f2) {
            int val = counts.get(f2) - counts.get(f1);
            if (val == 0) {
              val = f2 - f1;
            }
            return val;
          }

        };
      }

      @Override
      public Comparator<BrowseFacet> newComparator() {
        return new Comparator<BrowseFacet>() {
          @Override
          public int compare(BrowseFacet f1, BrowseFacet f2) {
            int val = f2.getFacetValueHitCount() - f1.getFacetValueHitCount();
            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

    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

    br.addSortField(new SortField("date", SortField.Type.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

    br.addSortField(new SortField("date", SortField.Type.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

    br.addSortField(new SortField("date", SortField.Type.CUSTOM, true));

    HashMap<String, List<BrowseFacet>> answer = new HashMap<String, List<BrowseFacet>>();
    answer.put("color",
      Arrays.asList(new BrowseFacet[] { new BrowseFacet("green", 1), new BrowseFacet("red", 1) }));
    doTest(br, 2, answer, new String[] { "6", "7" });
  }
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.