class DetectorMappingRepositoryImpl implements DetectorMappingRepository {

    @Override
    public List<DetectorMapping> search(SearchMappingsRequest request) {
        val query = QueryBuilders.boolQuery();
        if (request.getUserId() != null) {
            query.must(userIdQuery(request));
        }
        if (request.getDetectorUuid() != null) {
            query.must(detectorIdQuery(request));
        }

        val searchSourceBuilder = elasticsearchUtil.getSourceBuilder(query);
        //FIXME setting default result set size to 500 until we have pagination.
        searchSourceBuilder.size(500);
        SearchRequest searchRequest = elasticsearchUtil.getSearchRequest(searchSourceBuilder, elasticSearchProperties.getIndexName(), elasticSearchProperties.getDocType());
        List<DetectorMapping> result = getDetectorMappings(searchRequest);
        //FIXME - move this condition to search query.
        return result.stream().filter(detectorMapping -> detectorMapping.isEnabled()).collect(Collectors.toList());
    }

    @Autowired public  DetectorMappingRepositoryImpl(MetricRegistry metricRegistry);

}