Package org.apache.lucene.facet.params

Examples of org.apache.lucene.facet.params.CategoryListParams


    requests.add(new CountFacetRequest(new CategoryPath("b"), 10));
    requests.add(new CountFacetRequest(new CategoryPath("b" + FacetIndexingParams.DEFAULT_FACET_DELIM_CHAR), 10));

    final boolean doDimCount = random().nextBoolean();

    CategoryListParams clp = new CategoryListParams() {
        @Override
        public OrdinalPolicy getOrdinalPolicy(String dimension) {
          return doDimCount ? OrdinalPolicy.NO_PARENTS : OrdinalPolicy.ALL_BUT_DIMENSION;
        }
      };
View Full Code Here


    }
    HashMap<CategoryListParams,Iterable<CategoryPath>> categoryLists =
        new HashMap<CategoryListParams,Iterable<CategoryPath>>();
    for (CategoryPath cp : categories) {
      // each category may be indexed under a different field, so add it to the right list.
      CategoryListParams clp = indexingParams.getCategoryListParams(cp);
      List<CategoryPath> list = (List<CategoryPath>) categoryLists.get(clp);
      if (list == null) {
        list = new ArrayList<CategoryPath>();
        categoryLists.put(clp, list);
      }
View Full Code Here

    // for each CLP we add a different field for drill-down terms as well as for
    // counting list data.
    IntsRef ordinals = new IntsRef(32); // should be enough for most common applications
    for (Entry<CategoryListParams, Iterable<CategoryPath>> e : categoryLists.entrySet()) {
      final CategoryListParams clp = e.getKey();
      final String field = clp.field;

      // build category list data
      ordinals.length = 0; // reset
      int maxNumOrds = 0;
View Full Code Here

        return partitionSize;
      }
     
      @Override
      public CategoryListParams getCategoryListParams(CategoryPath category) {
        return new CategoryListParams() {
          @Override
          public OrdinalPolicy getOrdinalPolicy(String dimension) {
            return OrdinalPolicy.ALL_PARENTS;
          }
        };
View Full Code Here

   
    int partitionSize = fip.getPartitionSize();
    int numPartitions = (int) Math.ceil(taxoReader.getSize() / (double) partitionSize);
    final IntsRef ordinals = new IntsRef(32);
    for (String dim : DIMENSIONS) {
      CategoryListParams clp = fip.getCategoryListParams(new CategoryPath(dim));
      int partitionOffset = 0;
      for (int partition = 0; partition < numPartitions; partition++, partitionOffset += partitionSize) {
        final CategoryListIterator cli = clp.createCategoryListIterator(partition);
        for (AtomicReaderContext context : indexReader.leaves()) {
          if (cli.setNextReader(context)) { // not all fields may exist in all segments
            // remove that field from the list of DocValues fields
            docValuesFields.remove(clp.field + PartitionsUtils.partitionName(partition));
            int maxDoc = context.reader().maxDoc();
View Full Code Here

    Directory indexDir = newDirectory();
    Directory taxoDir = newDirectory();
   
    // set custom CLP fields for two dimensions and use the default ($facets) for the other two
    HashMap<CategoryPath,CategoryListParams> params = new HashMap<CategoryPath,CategoryListParams>();
    params.put(new CategoryPath(DIMENSIONS[0]), new CategoryListParams(DIMENSIONS[0]) {
      @Override
      public OrdinalPolicy getOrdinalPolicy(String dimension) {
        return OrdinalPolicy.ALL_PARENTS;
      }
    });
    params.put(new CategoryPath(DIMENSIONS[1]), new CategoryListParams(DIMENSIONS[1]) {
      @Override
      public OrdinalPolicy getOrdinalPolicy(String dimension) {
        return OrdinalPolicy.ALL_PARENTS;
      }
    });
View Full Code Here

    assertEquals("default partition size is unbounded", Integer.MAX_VALUE, ifip.getPartitionSize());
  }

  @Test
  public void testCategoryListParamsAddition() {
    CategoryListParams clp = new CategoryListParams("clp");
    PerDimensionIndexingParams tlfip = new PerDimensionIndexingParams(
        Collections.<CategoryPath,CategoryListParams> singletonMap(new CategoryPath("a"), clp));
    assertEquals("Expected category list field is " + clp.field,
        clp.field, tlfip.getCategoryListParams(new CategoryPath("a")).field);
    assertNotSame("Unexpected default category list " + clp.field, clp, tlfip.getCategoryListParams(null));
View Full Code Here

public class CategoryListParamsTest extends FacetTestCase {

  @Test
  public void testDefaultSettings() {
    CategoryListParams clp = new CategoryListParams();
    assertEquals("wrong default field", "$facets", clp.field);
    IntEncoder encoder = new SortingIntEncoder(new UniqueValuesIntEncoder(new DGapVInt8IntEncoder()));
    IntDecoder decoder = encoder.createMatchingDecoder();
    assertEquals("unexpected default encoder", encoder.toString(), clp.createEncoder().toString());
    assertEquals("unexpected default decoder", decoder.toString(), clp.createEncoder().createMatchingDecoder().toString());
  }
View Full Code Here

   * Test that the {@link CategoryListParams#hashCode()} and
   * {@link CategoryListParams#equals(Object)} are consistent.
   */
  @Test
  public void testIdentity() {
    CategoryListParams clParams1 = new CategoryListParams();
    // Assert identity is correct - a CategoryListParams equals itself.
    assertEquals("A CategoryListParams object does not equal itself.",
        clParams1, clParams1);
    // For completeness, the object's hashcode equals itself
    assertEquals("A CategoryListParams object's hashCode does not equal itself.",
        clParams1.hashCode(), clParams1.hashCode());
  }
View Full Code Here

   * other.
   */
  @Test
  public void testIdentityConsistency() {
    // Test 2 CategoryListParams with the default parameter
    CategoryListParams clParams1 = new CategoryListParams();
    CategoryListParams clParams2 = new CategoryListParams();
    assertEquals(
        "2 CategoryListParams with the same default term should equal each other.",
        clParams1, clParams2);
    assertEquals("2 CategoryListParams with the same default term should have the same hashcode",
        clParams1.hashCode(), clParams2.hashCode());

    // Test 2 CategoryListParams with the same specified Term
    clParams1 = new CategoryListParams("test");
    clParams2 = new CategoryListParams("test");
    assertEquals(
        "2 CategoryListParams with the same term should equal each other.",
        clParams1, clParams2);
    assertEquals("2 CategoryListParams with the same term should have the same hashcode",
        clParams1.hashCode(), clParams2.hashCode());
   
    // Test 2 CategoryListParams with DIFFERENT terms
    clParams1 = new CategoryListParams("test1");
    clParams2 = new CategoryListParams("test2");
    assertFalse(
        "2 CategoryListParams with the different terms should NOT equal each other.",
        clParams1.equals(clParams2));
    assertFalse(
        "2 CategoryListParams with the different terms should NOT have the same hashcode.",
        clParams1.hashCode() == clParams2.hashCode());
  }
View Full Code Here

TOP

Related Classes of org.apache.lucene.facet.params.CategoryListParams

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.