Java Code Examples for org.apache.solr.common.params.FacetParams#FACET_EXISTS

The following examples show how to use org.apache.solr.common.params.FacetParams#FACET_EXISTS . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SimpleFacets.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
/**
  * @param existsRequested facet.exists=true is passed for the given field
  * */
static FacetMethod selectFacetMethod(String fieldName, 
                                     SchemaField field, FacetMethod method, Integer mincount,
                                     boolean existsRequested) {
  if (existsRequested) {
    checkMincountOnExists(fieldName, mincount);
    if (method == null) {
      method = FacetMethod.ENUM;
    }
  }
  final FacetMethod facetMethod = selectFacetMethod(field, method, mincount);
  
  if (existsRequested && facetMethod!=FacetMethod.ENUM) {
    throw new SolrException (ErrorCode.BAD_REQUEST, 
        FacetParams.FACET_EXISTS + "=true is requested, but "+
        FacetParams.FACET_METHOD+"="+FacetParams.FACET_METHOD_enum+ " can't be used with "+fieldName
    );
  }
  return facetMethod;
}
 
Example 2
Source File: SimpleFacets.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
public static void checkMincountOnExists(String fieldName, int mincount) {
  if (mincount > 1) {
      throw new SolrException (ErrorCode.BAD_REQUEST,
          FacetParams.FACET_MINCOUNT + "="+mincount+" exceed 1 that's not supported with " + 
              FacetParams.FACET_EXISTS + "=true for " + fieldName
      );
    }
}