List of usage examples for org.apache.solr.common.params FacetParams FACET_METHOD_enum
String FACET_METHOD_enum
To view the source code for org.apache.solr.common.params FacetParams FACET_METHOD_enum.
Click Source Link
From source file:org.jahia.services.search.facets.SimpleJahiaJcrFacets.java
License:Open Source License
public NamedList<Object> getTermCounts(String field, ExtendedPropertyDefinition epd, String fieldNameInIndex, String locale) throws IOException, RepositoryException { int offset = params.getFieldInt(field, FacetParams.FACET_OFFSET, 0); int limit = params.getFieldInt(field, FacetParams.FACET_LIMIT, 100); if (limit == 0) return new NamedList<Object>(); Integer mincount = params.getFieldInt(field, FacetParams.FACET_MINCOUNT); if (mincount == null) { Boolean zeros = params.getFieldBool(field, FacetParams.FACET_ZEROS); // mincount = (zeros!=null && zeros) ? 0 : 1; mincount = (zeros != null && !zeros) ? 1 : 0; // current default is to include zeros. }//from w w w . java2 s .com boolean missing = params.getFieldBool(field, FacetParams.FACET_MISSING, false); // default to sorting if there is a limit. String sort = params.getFieldParam(field, FacetParams.FACET_SORT, limit > 0 ? FacetParams.FACET_SORT_COUNT : FacetParams.FACET_SORT_INDEX); String prefix = params.getFieldParam(field, FacetParams.FACET_PREFIX); NamedList<Object> counts; SchemaField sf = new SchemaField(fieldNameInIndex, getType(epd)); FieldType ft = sf.getType(); // determine what type of faceting method to use String method = params.getFieldParam(field, FacetParams.FACET_METHOD); boolean enumMethod = FacetParams.FACET_METHOD_enum.equals(method); if (method == null && ft instanceof BoolField) { // Always use filters for booleans... we know the number of values is very small. enumMethod = true; } boolean multiToken = epd.isMultiple(); // --> added by jahia as we don't use the UnInvertedField class yet due to not using SolrIndexSearcher enumMethod = enumMethod || multiToken; // if (TrieField.getMainValuePrefix(ft) != null) { // // A TrieField with multiple parts indexed per value... currently only // // UnInvertedField can handle this case, so force it's use. // enumMethod = false; // multiToken = true; // } // unless the enum method is explicitly specified, use a counting method. if (enumMethod) { // Always use filters for booleans... we know the number of values is very small. counts = getFacetTermEnumCounts(searcher, docs, field, fieldNameInIndex, offset, limit, mincount, missing, sort, prefix, epd.isInternationalized() ? (locale == null ? "" : locale) : null, epd); } else { // if (multiToken) { // UnInvertedField uif = UnInvertedField.getUnInvertedField(field, searcher); // counts = uif.getCounts(searcher, base, offset, limit, mincount,missing,sort,prefix); // } else { // TODO: future logic could use filters instead of the fieldcache if // the number of terms in the field is small enough. counts = getFieldCacheCounts(searcher, docs, fieldNameInIndex, offset, limit, mincount, missing, sort, prefix, epd.isInternationalized() ? (locale == null ? "" : locale) : null, epd); // } } return counts; }