Examples of FacetIndexingParams


Examples of org.apache.lucene.facet.index.params.FacetIndexingParams

  private void doTestCLParamMultiIteratorsByRequest(boolean cacheCLI) throws Exception,
      CorruptIndexException, IOException {
    // Create a CLP which generates different CLIs according to the
    // FacetRequest's dimension
    CategoryListParams clp = new CategoryListParams();
    FacetIndexingParams iParams = new DefaultFacetIndexingParams(clp);
    Directory indexDir = newDirectory();
    Directory taxoDir = newDirectory();
    populateIndex(iParams, indexDir, taxoDir);

    TaxonomyReader taxo = new LuceneTaxonomyReader(taxoDir);
View Full Code Here

Examples of org.apache.lucene.facet.index.params.FacetIndexingParams

  @Test
  public void testStreamNonTopLevelParams() throws IOException {
    Directory directory = newDirectory();
    final TaxonomyWriter taxonomyWriter = new LuceneTaxonomyWriter(
        directory);
    FacetIndexingParams indexingParams = new DefaultFacetIndexingParams() {
      @Override
      protected OrdinalPolicy fixedOrdinalPolicy() {
        return new NonTopLevelOrdinalPolicy();
      }
      @Override
View Full Code Here

Examples of org.apache.lucene.facet.index.params.FacetIndexingParams

  public void testRetainableAttributes() throws IOException, FacetException {
    Directory directory = newDirectory();
    TaxonomyWriter taxonomyWriter = new LuceneTaxonomyWriter(
        directory);

    FacetIndexingParams indexingParams = new DefaultFacetIndexingParams();
    new CategoryParentsStream(new CategoryAttributesStream(
        categoryContainer), taxonomyWriter, indexingParams);

    // add DummyAttribute and retain it, three expected
    categoryContainer.clear();
View Full Code Here

Examples of org.apache.lucene.facet.index.params.FacetIndexingParams

public class PerDimensionIndexingParamsTest extends LuceneTestCase {

  @Test
  public void testTopLevelSettings() {
    FacetIndexingParams ifip = new PerDimensionIndexingParams();
    assertNotNull("Missing default category list", ifip
        .getAllCategoryListParams());
    assertEquals(
        "Expected default category list term is $facets:$fulltree$",
        new Term("$facets", "$fulltree$"), ifip.getCategoryListParams(
            null).getTerm());
    String expectedDDText = "a"
        + ifip.getFacetDelimChar() + "b";
    CategoryPath cp = new CategoryPath("a", "b");
    assertEquals("wrong drill-down term", new Term("$facets",
        expectedDDText), DrillDown.term(ifip,cp));
    char[] buf = new char[20];
    int numchars = ifip.drillDownTermText(cp, buf);
    assertEquals("3 characters should be written", 3, numchars);
    assertEquals("wrong drill-down term text", expectedDDText, new String(
        buf, 0, numchars));
   
    CategoryListParams clParams = ifip.getCategoryListParams(null);
    assertEquals("partition for all ordinals is the first", "$fulltree$",
        PartitionsUtils.partitionNameByOrdinal(ifip, clParams , 250));
    assertEquals("for partition 0, the same name should be returned",
        "$fulltree$", PartitionsUtils.partitionName(clParams, 0));
    assertEquals(
        "for any other, it's the concatenation of name + partition",
        "$fulltree$1", PartitionsUtils.partitionName(clParams, 1));
    assertEquals("default partition number is always 0", 0,
        PartitionsUtils.partitionNumber(ifip,100));
   
    assertEquals("default partition size is unbounded", Integer.MAX_VALUE,
        ifip.getPartitionSize());
  }
View Full Code Here

Examples of org.apache.lucene.facet.index.params.FacetIndexingParams

public class DefaultFacetIndexingParamsTest extends LuceneTestCase {

  @Test
  public void testDefaultSettings() {
    FacetIndexingParams dfip = new DefaultFacetIndexingParams();
    assertNotNull("Missing default category list", dfip
        .getAllCategoryListParams());
    assertEquals(
        "all categories have the same CategoryListParams by default",
        dfip.getCategoryListParams(null), dfip
            .getCategoryListParams(new CategoryPath("a")));
    assertEquals(
        "Expected default category list term is $facets:$fulltree$",
        new Term("$facets", "$fulltree$"), dfip.getCategoryListParams(
            null).getTerm());
    String expectedDDText = "a"
        + dfip.getFacetDelimChar() + "b";
    CategoryPath cp = new CategoryPath("a", "b");
    assertEquals("wrong drill-down term", new Term("$facets",
        expectedDDText), DrillDown.term(dfip,cp));
    char[] buf = new char[20];
    int numchars = dfip.drillDownTermText(cp, buf);
    assertEquals("3 characters should be written", 3, numchars);
    assertEquals("wrong drill-down term text", expectedDDText, new String(
        buf, 0, numchars));
    CategoryListParams clParams = dfip.getCategoryListParams(null);
    assertEquals("partition for all ordinals is the first", "$fulltree$",
        PartitionsUtils.partitionNameByOrdinal(dfip, clParams , 250));
    assertEquals("for partition 0, the same name should be returned",
        "$fulltree$", PartitionsUtils.partitionName(clParams, 0));
    assertEquals(
        "for any other, it's the concatenation of name + partition",
        "$fulltree$1", PartitionsUtils.partitionName(clParams, 1));
    assertEquals("default partition number is always 0", 0,
        PartitionsUtils.partitionNumber(dfip,100));
    assertEquals("default partition size is unbounded", Integer.MAX_VALUE,
        dfip.getPartitionSize());
  }
View Full Code Here

Examples of org.apache.lucene.facet.index.params.FacetIndexingParams

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

Examples of org.apache.lucene.facet.index.params.FacetIndexingParams

        clp.getTerm(), dfip.getCategoryListParams(null).getTerm());
  }

  @Test
  public void testCategoryPolicies() {
    FacetIndexingParams dfip = new DefaultFacetIndexingParams();
    long seed = System.currentTimeMillis();
    // check path policy
    CategoryPath cp = new CategoryPath();
    PathPolicy pathPolicy = new DefaultPathPolicy();
    assertEquals("path policy does not match default for root" + "(seed "
        + seed + ")", pathPolicy.shouldAdd(cp), dfip.getPathPolicy()
        .shouldAdd(cp));
    for (int i = 0; i < 30; i++) {
      int nComponents = random.nextInt(10);
      String[] components = new String[nComponents];
      for (int j = 0; j < components.length; j++) {
        components[j] = (Integer.valueOf(random.nextInt(30))).toString();
      }
      cp = new CategoryPath(components);
      assertEquals("path policy does not match default for "
          + cp.toString('/') + "(seed " + seed + ")", pathPolicy
          .shouldAdd(cp), dfip.getPathPolicy().shouldAdd(cp));
    }

    // check ordinal policy
    OrdinalPolicy ordinalPolicy = new DefaultOrdinalPolicy();
    assertEquals("ordinal policy does not match default for root"
        + "(seed " + seed + ")", ordinalPolicy
        .shouldAdd(TaxonomyReader.ROOT_ORDINAL), dfip
        .getOrdinalPolicy().shouldAdd(TaxonomyReader.ROOT_ORDINAL));
    for (int i = 0; i < 30; i++) {
      int ordinal = random.nextInt();
      assertEquals("ordinal policy does not match default for " + ordinal
          + "(seed " + seed + ")", ordinalPolicy.shouldAdd(ordinal),
          dfip.getOrdinalPolicy().shouldAdd(ordinal));
    }
  }
View Full Code Here

Examples of org.apache.lucene.facet.index.params.FacetIndexingParams

    CountFacetRequest frq = new CountFacetRequest(cp, 10);
    FacetSearchParams sParams = getFacetedSearchParams();
    sParams.addFacetRequest(frq);
    if (withCache) {
      //let's use a cached cl data
      FacetIndexingParams iparams = sParams.getFacetIndexingParams();
      CategoryListParams clp = new CategoryListParams(); // default term ok as only single list
      CategoryListCache clCache = new CategoryListCache();
      clCache.loadAndRegister(clp, indexReader, taxoReader, iparams);
      if (plantWrongData) {
        // let's mess up the cached data and then expect a wrong result...
View Full Code Here

Examples of org.apache.lucene.facet.index.params.FacetIndexingParams

    iw.addDocument(d);
  }
 
  /** Build the "truth" with ALL the facets enumerating indexes content. */
  protected Map<CategoryPath, Integer> facetCountsTruth() throws IOException {
    FacetIndexingParams iParams = getFacetIndexingParams(Integer.MAX_VALUE);
    String delim = String.valueOf(iParams.getFacetDelimChar());
    Map<CategoryPath, Integer> res = new HashMap<CategoryPath, Integer>();
    HashSet<Term> handledTerms = new HashSet<Term>();
    for (CategoryListParams clp : iParams.getAllCategoryListParams()) {
      Term baseTerm = clp.getTerm().createTerm("");
      if (!handledTerms.add(baseTerm)) {
        continue; // already handled this term (for another list)
      }
      TermEnum te = indexReader.terms(baseTerm);
View Full Code Here

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

  protected HashMap<CategoryListIterator, Aggregator> getCategoryListMap(FacetArrays facetArrays,
      int partition) throws IOException {
   
    HashMap<CategoryListIterator, Aggregator> categoryLists = new HashMap<CategoryListIterator, Aggregator>();

    FacetIndexingParams indexingParams = searchParams.indexingParams;
    for (FacetRequest facetRequest : searchParams.facetRequests) {
      Aggregator categoryAggregator = createAggregator(facetRequest, facetArrays);

      CategoryListIterator cli = indexingParams.getCategoryListParams(facetRequest.categoryPath).createCategoryListIterator(partition);
     
      // get the aggregator
      Aggregator old = categoryLists.put(cli, categoryAggregator);

      if (old != null && !old.equals(categoryAggregator)) {
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.