use of ddf.catalog.operation.TermFacetProperties in project ddf by codice.
the class SolrMetacardClientImpl method handleFacetRequest.
private boolean handleFacetRequest(SolrQuery query, QueryRequest request) {
boolean isFacetedQuery = false;
Serializable textFacetPropRaw = request.getPropertyValue(EXPERIMENTAL_FACET_PROPERTIES_KEY);
if (textFacetPropRaw instanceof TermFacetProperties) {
TermFacetProperties textFacetProp = (TermFacetProperties) textFacetPropRaw;
isFacetedQuery = true;
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Enabling faceted query for request [{}] on field {}", request, textFacetProp);
}
textFacetProp.getFacetAttributes().stream().map(this::addAttributeTypeSuffix).filter(attr -> attr.contains(String.valueOf(FIRST_CHAR_OF_SUFFIX))).forEach(query::addFacetField);
query.setFacetSort(textFacetProp.getSortKey().name().toLowerCase());
query.setFacetLimit(textFacetProp.getFacetLimit());
query.setFacetMinCount(textFacetProp.getMinFacetCount());
}
return isFacetedQuery;
}
use of ddf.catalog.operation.TermFacetProperties in project ddf by codice.
the class FacetAttributeAccessPlugin method processPreQuery.
@Override
public QueryRequest processPreQuery(QueryRequest input) throws StopProcessingException {
if (input.getProperties().get(EXPERIMENTAL_FACET_PROPERTIES_KEY) instanceof TermFacetProperties) {
TermFacetProperties facetProperties = (TermFacetProperties) input.getProperties().get(EXPERIMENTAL_FACET_PROPERTIES_KEY);
Set<String> facetAttributes = facetProperties.getFacetAttributes();
for (String attr : facetAttributes) {
if (!config.getFacetAttributeWhitelist().contains(attr)) {
throw new StopProcessingException("Invalid Facet Attribute Detected: " + attr);
}
}
}
return input;
}
Aggregations