use of org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequest in project crate by crate.
the class DDLIntegrationTest method testCreateTableWithCompositeIndex.
@Test
public void testCreateTableWithCompositeIndex() throws Exception {
execute("create table novels (title string, description string, " + "index title_desc_fulltext using fulltext(title, description) " + "with(analyzer='english')) with (number_of_replicas = 0)");
ensureYellow();
assertTrue(client().admin().indices().exists(new IndicesExistsRequest("novels")).actionGet().isExists());
String title = "So Long, and Thanks for All the Fish";
String description = "Many were increasingly of the opinion that they'd all made a big " + "mistake in coming down from the trees in the first place. And some said that " + "even the trees had been a bad move, and that no one should ever have left " + "the oceans.";
execute("insert into novels (title, description) values(?, ?)", new Object[] { title, description });
refresh();
// match token existing at field `title`
execute("select title, description from novels where match(title_desc_fulltext, 'fish')");
assertEquals(1L, response.rowCount());
assertEquals(title, response.rows()[0][0]);
assertEquals(description, response.rows()[0][1]);
// match token existing at field `description`
execute("select title, description from novels where match(title_desc_fulltext, 'oceans')");
assertEquals(1L, response.rowCount());
assertEquals(title, response.rows()[0][0]);
assertEquals(description, response.rows()[0][1]);
// filtering on the actual values does still work
execute("select title from novels where title = ?", new Object[] { title });
assertEquals(1L, response.rowCount());
}
use of org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequest in project crate by crate.
the class DDLIntegrationTest method testCreateTableWithIndexOff.
@Test
public void testCreateTableWithIndexOff() throws Exception {
execute("create table quotes (id int, quote string index off) with (number_of_replicas = 0)");
ensureYellow();
assertTrue(client().admin().indices().exists(new IndicesExistsRequest("quotes")).actionGet().isExists());
String quote = "Would it save you a lot of time if I just gave up and went mad now?";
execute("insert into quotes (id, quote) values (?, ?)", new Object[] { 1, quote });
refresh();
execute("select quote from quotes where quote = ?", new Object[] { quote });
assertEquals(0, response.rowCount());
execute("select quote from quotes where id = 1");
assertEquals(1L, response.rowCount());
assertEquals(quote, response.rows()[0][0]);
}
use of org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequest in project crate by crate.
the class DDLIntegrationTest method testCreateTableWithInlineDefaultIndex.
@Test
public void testCreateTableWithInlineDefaultIndex() throws Exception {
execute("create table quotes (quote string index using plain) with (number_of_replicas = 0)");
ensureYellow();
assertTrue(client().admin().indices().exists(new IndicesExistsRequest("quotes")).actionGet().isExists());
String quote = "Would it save you a lot of time if I just gave up and went mad now?";
execute("insert into quotes values (?)", new Object[] { quote });
refresh();
// matching does not work on plain indexes
execute("select quote from quotes where match(quote, 'time')");
assertEquals(0, response.rowCount());
// filtering on the actual value does work
execute("select quote from quotes where quote = ?", new Object[] { quote });
assertEquals(1L, response.rowCount());
assertEquals(quote, response.rows()[0][0]);
}
use of org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequest in project crate by crate.
the class DDLIntegrationTest method testCreateTableWithReplicasAndShards.
@Test
public void testCreateTableWithReplicasAndShards() throws Exception {
execute("create table test (col1 integer primary key, col2 string)" + "clustered by (col1) into 10 shards with (number_of_replicas=2)");
assertTrue(client().admin().indices().exists(new IndicesExistsRequest("test")).actionGet().isExists());
String expectedMapping = "{\"default\":{" + "\"dynamic\":\"true\"," + "\"_meta\":{" + "\"primary_keys\":[\"col1\"]," + "\"routing\":\"col1\"}," + "\"_all\":{\"enabled\":false}," + "\"properties\":{" + "\"col1\":{\"type\":\"integer\"}," + "\"col2\":{\"type\":\"string\",\"index\":\"not_analyzed\"}" + "}}}";
String expectedSettings = "{\"test\":{" + "\"settings\":{" + "\"index.number_of_replicas\":\"2\"," + "\"index.number_of_shards\":\"10\"," + "\"index.version.created\":\"" + Version.CURRENT.esVersion.id + "\"" + "}}}";
JSONAssert.assertEquals(expectedMapping, getIndexMapping("test"), JSONCompareMode.LENIENT);
JSONAssert.assertEquals(expectedSettings, getIndexSettings("test"), JSONCompareMode.LENIENT);
}
use of org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequest in project elasticsearch by elastic.
the class IndicesExistsIT method testIndicesExists.
// Indices exists never throws IndexMissingException, the indices options control its behaviour (return true or false)
public void testIndicesExists() throws Exception {
assertFalse(client().admin().indices().prepareExists("foo").get().isExists());
assertFalse(client().admin().indices().prepareExists("foo*").get().isExists());
assertFalse(client().admin().indices().prepareExists("_all").get().isExists());
createIndex("foo", "foobar", "bar", "barbaz");
IndicesExistsRequestBuilder indicesExistsRequestBuilder = client().admin().indices().prepareExists("foo*").setExpandWildcardsOpen(false);
IndicesExistsRequest request = indicesExistsRequestBuilder.request();
//check that ignore unavailable and allow no indices are set to false. That is their only valid value as it can't be overridden
assertFalse(request.indicesOptions().ignoreUnavailable());
assertFalse(request.indicesOptions().allowNoIndices());
assertThat(indicesExistsRequestBuilder.get().isExists(), equalTo(false));
assertAcked(client().admin().indices().prepareClose("foobar").get());
assertThat(client().admin().indices().prepareExists("foo*").get().isExists(), equalTo(true));
assertThat(client().admin().indices().prepareExists("foo*").setExpandWildcardsOpen(false).setExpandWildcardsClosed(false).get().isExists(), equalTo(false));
assertThat(client().admin().indices().prepareExists("foobar").get().isExists(), equalTo(true));
assertThat(client().admin().indices().prepareExists("foob*").setExpandWildcardsClosed(false).get().isExists(), equalTo(false));
assertThat(client().admin().indices().prepareExists("bar*").get().isExists(), equalTo(true));
assertThat(client().admin().indices().prepareExists("bar").get().isExists(), equalTo(true));
assertThat(client().admin().indices().prepareExists("_all").get().isExists(), equalTo(true));
}
Aggregations