@Override
    public void search(final TaskContext taskContext,
                       final StatisticStoreDoc statisticStoreEntity,
                       final FindEventCriteria criteria,
                       final FieldIndex fieldIndex,
                       final ValuesConsumer valuesConsumer,
                       final ErrorConsumer errorConsumer) {
        try {
            final List<String> selectCols = getSelectColumns(statisticStoreEntity, fieldIndex);
            final Optional<SqlBuilder> optSql = buildSql(statisticStoreEntity, criteria, fieldIndex);

            // If there is nothing to select then there is nothing to pass to the value consumer
            optSql.ifPresent(sql -> {
                // build a mapper function to convert a resultSet row into a String[] based on the fields
                // required by all coprocessors
                Function<ResultSet, Val[]> resultSetMapper = buildResultSetMapper(fieldIndex, statisticStoreEntity);

                // the query will not be executed until somebody subscribes to the flowable
                getFlowableQueryResults(taskContext, sql, resultSetMapper, valuesConsumer);
            });
        } catch (final RuntimeException e) {
            errorConsumer.add(e);
        }
    }
TODO: This is a bit simplistic as a user could create a filter that said
user=user1 AND user='*' which makes no sense. At the moment we would
assume that the user tag is being rolled up so user=user1 would never be
found in the data and thus would return no data.
stroom-statistics/stroom-statistics-impl-sql/src/main/java/stroom/statistics/impl/sql/search/StatisticsSearchServiceImpl.java