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];
}
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;
}
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]);
}
}
}
}
Aggregations