Search in sources :

Example 1 with CardinalityAggregator

use of datawave.query.jexl.functions.CardinalityAggregator 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;
}
Also used : JexlEvaluation(datawave.query.function.JexlEvaluation) FacetedConfiguration(datawave.query.tables.facets.FacetedConfiguration) FacetedSearchType(datawave.query.tables.facets.FacetedSearchType) MalformedURLException(java.net.MalformedURLException) ConfigException(org.apache.zookeeper.server.quorum.QuorumPeerConfig.ConfigException) IOException(java.io.IOException) CardinalityAggregator(datawave.query.jexl.functions.CardinalityAggregator)

Aggregations

JexlEvaluation (datawave.query.function.JexlEvaluation)1 CardinalityAggregator (datawave.query.jexl.functions.CardinalityAggregator)1 FacetedConfiguration (datawave.query.tables.facets.FacetedConfiguration)1 FacetedSearchType (datawave.query.tables.facets.FacetedSearchType)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 ConfigException (org.apache.zookeeper.server.quorum.QuorumPeerConfig.ConfigException)1