Search in sources :

Example 6 with DimConfig

use of org.apache.lucene.facet.FacetsConfig.DimConfig in project lucene-solr by apache.

the class FloatTaxonomyFacets method getSpecificValue.

@Override
public Number getSpecificValue(String dim, String... path) throws IOException {
    DimConfig dimConfig = verifyDim(dim);
    if (path.length == 0) {
        if (dimConfig.hierarchical && dimConfig.multiValued == false) {
        // ok: rolled up at search time
        } else if (dimConfig.requireDimCount && dimConfig.multiValued) {
        // ok: we indexed all ords at index time
        } else {
            throw new IllegalArgumentException("cannot return dimension-level value alone; use getTopChildren instead");
        }
    }
    int ord = taxoReader.getOrdinal(new FacetLabel(dim, path));
    if (ord < 0) {
        return -1;
    }
    return values[ord];
}
Also used : DimConfig(org.apache.lucene.facet.FacetsConfig.DimConfig)

Example 7 with DimConfig

use of org.apache.lucene.facet.FacetsConfig.DimConfig in project lucene-solr by apache.

the class TaxonomyFacets method getAllDims.

@Override
public List<FacetResult> getAllDims(int topN) throws IOException {
    int ord = children[TaxonomyReader.ROOT_ORDINAL];
    List<FacetResult> results = new ArrayList<>();
    while (ord != TaxonomyReader.INVALID_ORDINAL) {
        String dim = taxoReader.getPath(ord).components[0];
        FacetsConfig.DimConfig dimConfig = config.getDimConfig(dim);
        if (dimConfig.indexFieldName.equals(indexFieldName)) {
            FacetResult result = getTopChildren(topN, dim);
            if (result != null) {
                results.add(result);
            }
        }
        ord = siblings[ord];
    }
    // Sort by highest value, tie break by dim:
    Collections.sort(results, BY_VALUE_THEN_DIM);
    return results;
}
Also used : FacetsConfig(org.apache.lucene.facet.FacetsConfig) ArrayList(java.util.ArrayList) FacetResult(org.apache.lucene.facet.FacetResult) DimConfig(org.apache.lucene.facet.FacetsConfig.DimConfig)

Example 8 with DimConfig

use of org.apache.lucene.facet.FacetsConfig.DimConfig in project lucene-solr by apache.

the class IntTaxonomyFacets method rollup.

/** Rolls up any single-valued hierarchical dimensions. */
protected void rollup() throws IOException {
    // Rollup any necessary dims:
    for (Map.Entry<String, DimConfig> ent : config.getDimConfigs().entrySet()) {
        String dim = ent.getKey();
        DimConfig ft = ent.getValue();
        if (ft.hierarchical && ft.multiValued == false) {
            int dimRootOrd = taxoReader.getOrdinal(new FacetLabel(dim));
            // config but never indexed:
            if (dimRootOrd > 0) {
                values[dimRootOrd] += rollup(children[dimRootOrd]);
            }
        }
    }
}
Also used : Map(java.util.Map) DimConfig(org.apache.lucene.facet.FacetsConfig.DimConfig)

Aggregations

DimConfig (org.apache.lucene.facet.FacetsConfig.DimConfig)8 FacetResult (org.apache.lucene.facet.FacetResult)3 Map (java.util.Map)2 LabelAndValue (org.apache.lucene.facet.LabelAndValue)2 ArrayList (java.util.ArrayList)1 FacetsConfig (org.apache.lucene.facet.FacetsConfig)1 TopOrdAndFloatQueue (org.apache.lucene.facet.TopOrdAndFloatQueue)1 TopOrdAndIntQueue (org.apache.lucene.facet.TopOrdAndIntQueue)1 IndexReader (org.apache.lucene.index.IndexReader)1 Term (org.apache.lucene.index.Term)1