class DetectorMapper {

    public boolean isSuccessfulDetectorMappingLookup(List<Map<String, String>> cacheMissedMetricTags) {

        DetectorMatchResponse matchingDetectorMappings = getMappingsFromElasticSearch(cacheMissedMetricTags);
        if (matchingDetectorMappings != null) {
            lastElasticLookUpLatency.set(matchingDetectorMappings.getLookupTimeInMillis());
            Map<Integer, List<Detector>> groupedDetectorsByIndex = matchingDetectorMappings.getGroupedDetectorsBySearchIndex();
            populateCache(groupedDetectorsByIndex, cacheMissedMetricTags);
            Set<Integer> searchIndexes = groupedDetectorsByIndex.keySet();

            //For metrics with no matching detectors, set matching detectors to empty in cache to avoid repeated cache miss
            int i = 0;
            for (Map<String, String> tags : cacheMissedMetricTags) {
                if (!searchIndexes.contains(i)) {
                    String cacheKey = CacheUtil.getKey(tags);
                    cache.put(cacheKey, Collections.emptyList());
                }
                i++;
            }
        } else {
            lastElasticLookUpLatency.set(-2);
        }
        return matchingDetectorMappings != null;
    }

    public  DetectorMapper(DetectorSource detectorSource, DetectorMapperCache cache, int detectorCacheUpdateTimePeriod);
    public  DetectorMapper(DetectorSource detectorSource, Config config, MetricRegistry metricRegistry);

}