use of datawave.query.tables.facets.FacetedSearchType in project datawave by NationalSecurityAgency.
the class DynamicFacetIterator method validateOptions.
@Override
public boolean validateOptions(Map<String, String> options) {
boolean res = super.validateOptions(options);
configuration = new FacetedConfiguration();
FacetedSearchType type = FacetedSearchType.DAY_COUNT;
if (options.containsKey(FACETED_SEARCH_TYPE)) {
type = FacetedSearchType.valueOf(options.get(FACETED_SEARCH_TYPE));
}
configuration.setType(type);
if (options.containsKey(FACETED_MINIMUM)) {
try {
configuration.setMinimumCount(Integer.parseInt(options.get(FACETED_MINIMUM)));
} catch (NumberFormatException nfe) {
log.error(nfe);
// defaulting to 1
}
}
String fields = "";
if (options.containsKey(FACETED_SEARCH_FIELDS)) {
fields = options.get(FACETED_SEARCH_FIELDS);
}
switch(type) {
case SHARD_COUNT:
case DAY_COUNT:
try {
// Parse & flatten the query tree.
script = JexlASTHelper.parseAndFlattenJexlQuery(this.getQuery());
myEvaluationFunction = new JexlEvaluation(this.getQuery(), arithmetic);
} catch (Exception e) {
throw new RuntimeException("Could not parse the JEXL query: '" + this.getQuery() + "'", e);
}
break;
default:
break;
}
SortedSet<String> facetedFields = Sets.newTreeSet(Splitter.on(",").split(fields));
// indexed fields from the faceted field list.
if (!facetedFields.isEmpty())
configuration.setHasFieldLimits(true);
configuration.setFacetedFields(facetedFields);
fiAggregator = new CardinalityAggregator(getAllIndexOnlyFields(), !merge);
// assign the options for later use by the document iterator
documenIteratorOptions = options;
return res;
}
Aggregations