@SuppressWarnings("deprecation")
@Test
public void testMissingIndicesQuery() throws FoxtrotException {

    final ObjectMapper mapper = getMapper();
    List<Document> documents = TestUtils.getQueryDocumentsDifferentDate(mapper, new Date(2014 - 1900, 4, 1).getTime());
    documents.addAll(TestUtils.getQueryDocumentsDifferentDate(mapper, new Date(2014 - 1900, 4, 5).getTime()));
    getQueryStore().save(TestUtils.TEST_TABLE_NAME, documents);
    for(Document document : documents) {
        getElasticsearchConnection().getClient()
                .admin()
                .indices()
                .prepareRefresh(ElasticsearchUtils.getCurrentIndex(TestUtils.TEST_TABLE_NAME, document.getTimestamp()))
                .execute()
                .actionGet();
    }
    GetIndexResponse response = getElasticsearchConnection().getClient()
            .admin()
            .indices()
            .getIndex(new GetIndexRequest())
            .actionGet();
    // Find all indices returned for this table name.. (using regex to match)
    assertEquals(3, Arrays.stream(response.getIndices())
            .filter(index -> index.matches(".*-" + TestUtils.TEST_TABLE_NAME + "-.*"))
            .count());
    Query query = new Query();
    query.setLimit(documents.size());
    query.setTable(TestUtils.TEST_TABLE_NAME);
    BetweenFilter betweenFilter = new BetweenFilter();
    betweenFilter.setField("_timestamp");
    betweenFilter.setFrom(documents.get(0)
                                  .getTimestamp());
    betweenFilter.setTo(documents.get(documents.size() - 1)
                                .getTimestamp());
    betweenFilter.setTemporal(true);
    query.setFilters(Lists.<Filter>newArrayList(betweenFilter));
    QueryResponse actualResponse = QueryResponse.class.cast(getQueryExecutor().execute(query));
    assertEquals(documents.size(), actualResponse.getDocuments()
            .size());
}