Examples of CategoryListParams


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

        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

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

   
    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

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

    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

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

    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

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

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

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

   * 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

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

   * 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

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

        dfip.getPartitionSize());
  }

  @Test
  public void testCategoryListParamsWithDefaultIndexingParams() {
    CategoryListParams clp = new CategoryListParams("clp");
    FacetIndexingParams dfip = new FacetIndexingParams(clp);
    assertEquals("Expected default category list field is " + clp.field, clp.field, dfip.getCategoryListParams(null).field);
  }
View Full Code Here

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

   
    // build the PerDimensionIndexingParams
    HashMap<CategoryPath,CategoryListParams> clps = new HashMap<CategoryPath,CategoryListParams>();
    for (String dim : dimensions) {
      CategoryPath cp = new CategoryPath(dim);
      CategoryListParams clp = randomCategoryListParams("$" + dim);
      clps.put(cp, clp);
    }
    PerDimensionIndexingParams indexingParams = new PerDimensionIndexingParams(clps);
   
    // index some documents
    Directory indexDir = newDirectory();
    Directory taxoDir = newDirectory();
    IndexWriter indexWriter = new IndexWriter(indexDir, newIndexWriterConfig(TEST_VERSION_CURRENT, null).setMaxBufferedDocs(2));
    TaxonomyWriter taxoWriter = new DirectoryTaxonomyWriter(taxoDir);
    FacetFields facetFields = new FacetFields(taxoWriter, indexingParams);
    int ndocs = atLeast(random, 10);
    for (int i = 0; i < ndocs; i++) {
      Document doc = new Document();
      int numCategories = random.nextInt(numDimensions) + 1;
      ArrayList<CategoryPath> categories = new ArrayList<CategoryPath>();
      for (int j = 0; j < numCategories; j++) {
        String dimension = dimensions[random.nextInt(dimensions.length)];
        categories.add(new CategoryPath(dimension, Integer.toString(i)));
      }
      facetFields.addFields(doc, categories);
      indexWriter.addDocument(doc);
    }
    IOUtils.close(indexWriter, taxoWriter);
   
    // test the multi iterator
    DirectoryReader indexReader = DirectoryReader.open(indexDir);
    TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoDir);
    CategoryListIterator[] iterators = new CategoryListIterator[numDimensions];
    for (int i = 0; i < iterators.length; i++) {
      CategoryListParams clp = indexingParams.getCategoryListParams(new CategoryPath(dimensions[i]));
      IntDecoder decoder = clp.createEncoder().createMatchingDecoder();
      iterators[i] = new DocValuesCategoryListIterator(clp.field, decoder);
    }
    MultiCategoryListIterator cli = new MultiCategoryListIterator(iterators);
    for (AtomicReaderContext context : indexReader.leaves()) {
      assertTrue("failed to init multi-iterator", cli.setNextReader(context));
View Full Code Here

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

    BinaryDocValues inner = super.getBinaryDocValues(field);
    if (inner == null) {
      return inner;
    }
   
    CategoryListParams clp = dvFieldMap.get(field);
    if (clp == null) {
      return inner;
    } else {
      return new OrdinalMappingBinaryDocValues(clp, inner);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.