Package org.apache.lucene.facet.params

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


    }
    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

  /** Creates a new instance and populates the catetory list params mapping. */
  public MultiCategoryListsFacetsExample() {
    // index all Author facets in one category list and all Publish Date in another.
    Map<CategoryPath,CategoryListParams> categoryListParams = new HashMap<CategoryPath,CategoryListParams>();
    categoryListParams.put(new CategoryPath("Author"), new CategoryListParams("author"));
    categoryListParams.put(new CategoryPath("Publish Date"), new CategoryListParams("pubdate"));
    indexingParams = new PerDimensionIndexingParams(categoryListParams);
  }
View Full Code Here

   * message.
   */
  final static boolean verifySearchParams(FacetSearchParams fsp) {
    // verify that all category lists were encoded with DGapVInt
    for (FacetRequest fr : fsp.facetRequests) {
      CategoryListParams clp = fsp.indexingParams.getCategoryListParams(fr.categoryPath);
      if (clp.createEncoder().createMatchingDecoder().getClass() != DGapVInt8IntDecoder.class) {
        return false;
      }
    }
   
    return true;
View Full Code Here

*/
public final class DrillDownQuery extends Query {

  /** Return a drill-down {@link Term} for a category. */
  public static Term term(FacetIndexingParams iParams, CategoryPath path) {
    CategoryListParams clp = iParams.getCategoryListParams(path);
    char[] buffer = new char[path.fullPathLength()];
    iParams.drillDownTermText(path, buffer);
    return new Term(clp.field, String.valueOf(buffer));
  }
View Full Code Here

        root.label = fr.categoryPath;
        root.value = 0;
        res.add(new FacetResult(fr, root, 0));
        continue;
      }
      CategoryListParams clp = searchParams.indexingParams.getCategoryListParams(fr.categoryPath);
      OrdinalPolicy ordinalPolicy = clp .getOrdinalPolicy(fr.categoryPath.components[0]);
      if (ordinalPolicy == OrdinalPolicy.NO_PARENTS) {
        // rollup values
        aggregator.rollupValues(fr, rootOrd, children, siblings, facetArrays);
      }
     
View Full Code Here

    }

    final Map<CategoryListParams,Iterable<CategoryPath>> categoryLists = createCategoryListMapping(categories);
    for (Entry<CategoryListParams, Iterable<CategoryPath>> e : categoryLists.entrySet()) {

      CategoryListParams clp = e.getKey();
      String dvField = clp.field + SortedSetDocValuesReaderState.FACET_FIELD_EXTENSION;

      // Add sorted-set DV fields, one per value:
      for(CategoryPath cp : e.getValue()) {
        if (cp.length != 2) {
View Full Code Here

 
  /** Returns a {@link CategoryListParams} with random {@link IntEncoder}. */
  public static CategoryListParams randomCategoryListParams(String field) {
    Random random = random();
    final IntEncoder encoder = ENCODERS[random.nextInt(ENCODERS.length)];
    return new CategoryListParams(field) {
      @Override
      public IntEncoder createEncoder() {
        return encoder;
      }
    };
View Full Code Here

    Directory dir = newDirectory();
    Directory taxoDir = newDirectory();
    RandomIndexWriter writer = new RandomIndexWriter(random(), dir);
    DirectoryTaxonomyWriter taxoWriter = new DirectoryTaxonomyWriter(taxoDir, IndexWriterConfig.OpenMode.CREATE);

    CategoryListParams clp = new CategoryListParams("$facets") {
        @Override
        public OrdinalPolicy getOrdinalPolicy(String fieldName) {
          return OrdinalPolicy.ALL_PARENTS;
        }
      };
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.