@@ -0,0 +1,3038 @@
+/*%0A * Copyright (c) 2017 Strapdata (http://www.strapdata.com)%0A * Contains some code from Elasticsearch (http://www.elastic.co)%0A * %0A * Licensed under the Apache License, Version 2.0 (the %22License%22); you may not use this file except in compliance with%0A * the License. You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage org.elassandra;%0A%0Aimport org.apache.cassandra.db.ConsistencyLevel;%0Aimport org.elasticsearch.common.xcontent.XContentBuilder;%0Aimport org.elasticsearch.common.xcontent.XContentFactory;%0Aimport org.elasticsearch.index.query.QueryBuilders;%0Aimport org.elasticsearch.test.ESSingleNodeTestCase;%0Aimport org.junit.Test;%0A%0Aimport java.util.Locale;%0A%0Aimport static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;%0Aimport static org.hamcrest.Matchers.equalTo;%0A%0A/**%0A * Because of distribution (and Hinted Handoff) Cassandra may write events not properly time-ordered. %0A * This could lead to index in elasticsearch the last written row and not the up-to-date row.%0A * @author vroyer%0A *%0A */%0A//gradle :server:test -Dtests.seed=65E2CF27F286CC89 -Dtests.class=org.elassandra.ExplainTests -Dtests.security.manager=false -Dtests.locale=en-PH -Dtests.timezone=America/Coral_Harbour%0Apublic class ExplainTests extends ESSingleNodeTestCase %7B%0A%0A    @Test%0A    public void testExplain() throws Exception %7B%0A        XContentBuilder mapping = XContentFactory.jsonBuilder()%0A                .startObject()%0A                    .startObject(%22properties%22)%0A                        .startObject(%22id%22)%0A                            .field(%22type%22, %22keyword%22)%0A                            .field(%22cql_collection%22, %22singleton%22)%0A                            .field(%22cql_primary_key_order%22, 0)%0A                            .field(%22cql_partition_key%22, true)%0A                        .endObject()%0A                        .startObject(%22f1%22)%0A                            .field(%22type%22, %22integer%22)%0A                            .field(%22cql_collection%22, %22singleton%22)%0A                        .endObject()%0A                    .endObject()%0A                .endObject();%0A        assertAcked(client().admin().indices().prepareCreate(%22test%22).addMapping(%22t1%22, mapping));%0A        ensureGreen(%22test%22);%0A        %0A        long N = 10;%0A        for(int i=0; i %3C N; i++)%0A            process(ConsistencyLevel.ONE, String.format(Locale.ROOT, %22INSERT INTO test.t1 (id, f1) VALUES ('%25d',%25d)%22, i,i));%0A        assertThat(client().prepareSearch().setIndices(%22test%22).setQuery(QueryBuilders.termQuery(%22f1%22, 1)).get().getHits().getTotalHits(), equalTo(1L));%0A        assertThat(client().prepareExplain(%22test%22, %22t1%22, %221%22).setQuery(QueryBuilders.termQuery(%22f1%22, 1)).get().hasExplanation(), equalTo(true));%0A    %7D%0A%7D%0A%0A

Add explain action test