private Facets getFacets(String dim) { if (stateIndexField != null && stateIndexField.equals(config.getDimConfig(dim).indexFieldName)) return docValuesFacets; return taxonomyFacets; }
/** Throws {@code IllegalArgumentException} if the * dimension is not recognized. Otherwise, returns the * {@link DimConfig} for this dimension. */ protected FacetsConfig.DimConfig verifyDim(String dim) { FacetsConfig.DimConfig dimConfig = config.getDimConfig(dim); if (!dimConfig.indexFieldName.equals(indexFieldName)) { throw new IllegalArgumentException("dimension \"" + dim + "\" was not indexed into field \"" + indexFieldName); } return dimConfig; }
/** Throws {@code IllegalArgumentException} if the * dimension is not recognized. Otherwise, returns the * {@link DimConfig} for this dimension. */ protected FacetsConfig.DimConfig verifyDim(String dim) { FacetsConfig.DimConfig dimConfig = config.getDimConfig(dim); if (!dimConfig.indexFieldName.equals(indexFieldName)) { throw new IllegalArgumentException("dimension \"" + dim + "\" was not indexed into field \"" + indexFieldName + "\""); } return dimConfig; }
/** * Creates a new {@code MultiFacetQuery} filtering the query on the given dimension. */ public MultiFacetQuery(final FacetsConfig facetsConfig, final String dimension, final String[]... paths) { super(facetsConfig.getDimConfig(dimension).indexFieldName, toTerms(dimension, paths)); }
@Override final protected Facets getFacets(final String dimension) throws IOException { if (sortedSetFacetField.equals(facetsConfig.getDimConfig(dimension).indexFieldName)) { if (queryContext.docValueReaderState == null) return null; if (queryContext.docValueReaderState.getOrdRange(dimension) == null) return null; } return results.facets; } }
/** * Creates a new {@code FacetQuery} filtering the query on the given dimension. */ public FacetQuery(final FacetsConfig facetsConfig, final String dimension, final String... path) { super(toTerm(facetsConfig.getDimConfig(dimension), dimension, path)); }
private int checkFacetTypeFlags(final FacetsConfig facetsConfig, final LinkedHashMap<String, FacetDefinition> facetsDef) { int flag = 0; for (String dimName : facetsDef.keySet()) { final String resolvedDimension = resolvedDimensions.get(dimName); if (resolvedDimension == null) continue; final String indexField = facetsConfig.getDimConfig(resolvedDimension).indexFieldName; if (indexField == null) continue; if (indexField.equals(sortedSetFacetField)) { flag = flag | FACET_IS_SORTED; } else { switch (indexField) { case FieldDefinition.TAXONOMY_FACET_FIELD: flag = flag | FACET_IS_TAXO; break; case FieldDefinition.TAXONOMY_INT_ASSOC_FACET_FIELD: flag = flag | FACET_IS_TAXO_INT; break; case FieldDefinition.TAXONOMY_FLOAT_ASSOC_FACET_FIELD: flag = flag | FACET_IS_TAXO_FLOAT; break; default: break; } } } return flag; }
/** Adds one dimension of drill downs; if you pass the same * dimension more than once it is OR'd with the previous * cofnstraints on that dimension, and all dimensions are * AND'd against each other and the base query. */ public void add(String dim, String... path) { String indexedField = config.getDimConfig(dim).indexFieldName; add(dim, new TermQuery(term(indexedField, dim, path))); }
/** Adds one dimension of drill downs; if you pass the same * dimension more than once it is OR'd with the previous * cofnstraints on that dimension, and all dimensions are * AND'd against each other and the base query. */ public void add(String dim, String... path) { String indexedField = config.getDimConfig(dim).indexFieldName; add(dim, new TermQuery(term(indexedField, dim, path))); }
@Override final protected Facets getFacets(final String dimension) throws IOException { final String indexFieldName = facetsConfig.getDimConfig(dimension).indexFieldName; if (indexFieldName == null) return null; if (indexFieldName.equals(sortedSetFacetField)) { if (queryContext.docValueReaderState != null) if (queryContext.docValueReaderState.getOrdRange(dimension) != null) return sortedSetCounts; } else { switch (indexFieldName) { case FieldDefinition.TAXONOMY_FACET_FIELD: return taxonomyCounts; case FieldDefinition.TAXONOMY_INT_ASSOC_FACET_FIELD: return intTaxonomyCounts; case FieldDefinition.TAXONOMY_FLOAT_ASSOC_FACET_FIELD: return floatTaxonomyCounts; default: break; } } return null; } }
@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; }
@Override final public Query getQuery(final QueryContext queryContext) throws IOException { Objects.requireNonNull(dimension, "The dimension is missing"); final FieldMap fieldMap = queryContext.getFieldMap(); final String resolvedDimension = fieldMap == null ? dimension : fieldMap.resolveQueryFieldName(genericField, dimension); final String indexFieldName = queryContext.getFacetsConfig(genericField, dimension).getDimConfig(resolvedDimension).indexFieldName; final Term term = new Term(indexFieldName, FacetsConfig.pathToString(resolvedDimension, path)); return new org.apache.lucene.search.TermQuery(term); }
@Override public List<FacetResult> getAllDims(int topN) throws IOException { int[] children = getChildren(); int[] siblings = getSiblings(); 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; } }
private void processSSDVFacetFields(Map<String,List<SortedSetDocValuesFacetField>> byField, Document doc) throws IOException { //System.out.println("process SSDV: " + byField); for(Map.Entry<String,List<SortedSetDocValuesFacetField>> ent : byField.entrySet()) { String indexFieldName = ent.getKey(); //System.out.println(" field=" + indexFieldName); for(SortedSetDocValuesFacetField facetField : ent.getValue()) { FacetLabel cp = new FacetLabel(facetField.dim, facetField.label); String fullPath = pathToString(cp.components, cp.length); //System.out.println("add " + fullPath); // For facet counts: doc.add(new SortedSetDocValuesField(indexFieldName, new BytesRef(fullPath))); // For drill-down: doc.add(new StringField(indexFieldName, fullPath, Field.Store.NO)); FacetsConfig.DimConfig ft = getDimConfig(facetField.dim); if (ft.requireDimensionDrillDown) { doc.add(new StringField(indexFieldName, facetField.dim, Field.Store.NO)); } } } }
DimConfig dimConfig = config.getDimConfig(res.dim);
DimConfig dimConfig = config.getDimConfig(res.dim);
protected Facets buildFacetsResult(final FacetsCollector drillDowns, final FacetsCollector[] drillSideways, final String[] drillSidewaysDims) throws IOException { final Map<String, Facets> drillSidewaysFacets = new HashMap<>(); final FastTaxonomyFacetCounts fastTaxonomyFacets = taxoReader == null ? null : new FastTaxonomyFacetCounts( taxoReader, config, drillDowns); final SortedSetDocValuesFacetCounts docValuesFacets = state == null ? null : new SortedSetDocValuesFacetCounts( state, drillDowns); if (drillSideways != null) { for (int i = 0; i < drillSideways.length; i++) { final String dim = drillSidewaysDims[i]; final Facets facets; final String indexFieldName = config.getDimConfig(dim).indexFieldName; if (state != null && stateIndexField.equals(indexFieldName)) { facets = new SortedSetDocValuesFacetCounts(state, drillSideways[i]); } else if (taxoReader != null) { facets = new FastTaxonomyFacetCounts(taxoReader, config, drillSideways[i]); } else facets = null; if (facets != null) drillSidewaysFacets.put(dim, facets); } } final Facets facets = new MixedFacets(docValuesFacets, fastTaxonomyFacets); return drillSidewaysFacets.isEmpty() ? facets : new MultiFacets(drillSidewaysFacets, facets); }
upto += field.assoc.length; FacetsConfig.DimConfig ft = getDimConfig(field.dim);
for(FacetField facetField : ent.getValue()) { FacetsConfig.DimConfig ft = getDimConfig(facetField.dim); if (facetField.path.length > 1 && ft.hierarchical == false) { throw new IllegalArgumentException("dimension \"" + facetField.dim + "\" is not hierarchical yet has " + facetField.path.length + " components");
for(FacetField facetField : ent.getValue()) { FacetsConfig.DimConfig ft = getDimConfig(facetField.dim); if (facetField.path.length > 1 && ft.hierarchical == false) { throw new IllegalArgumentException("dimension \"" + facetField.dim + "\" is not hierarchical yet has " + facetField.path.length + " components");