本文整理汇总了Java中org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequestBuilder类的典型用法代码示例。如果您正苦于以下问题:Java IndicesExistsRequestBuilder类的具体用法?Java IndicesExistsRequestBuilder怎么用?Java IndicesExistsRequestBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IndicesExistsRequestBuilder类属于org.elasticsearch.action.admin.indices.exists.indices包,在下文中一共展示了IndicesExistsRequestBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testIndicesExists
import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequestBuilder; //导入依赖的package包/类
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));
}
示例2: testIndexExists
import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequestBuilder; //导入依赖的package包/类
@Test
public void testIndexExists() {
//Test data
final String indexName = "index";
final AdminClient adminClient = createMock(AdminClient.class);
final IndicesAdminClient indicesAdminClient = createMock(IndicesAdminClient.class);
final IndicesExistsRequestBuilder indicesExistsRequestBuilder = createMock(IndicesExistsRequestBuilder.class);
final IndicesExistsResponse indicesExistsResponse = createMock(IndicesExistsResponse.class);
final boolean exists = new Random().nextBoolean();
//Reset
resetAll();
//Expectations
expect(esClient.admin()).andReturn(adminClient);
expect(adminClient.indices()).andReturn(indicesAdminClient);
expect(indicesAdminClient.prepareExists(indexName)).andReturn(indicesExistsRequestBuilder);
expect(indicesExistsRequestBuilder.get()).andReturn(indicesExistsResponse);
expect(indicesExistsResponse.isExists()).andReturn(exists);
//Replay
replayAll();
//Run test scenario
final boolean result = elasticsearchClientWrapper.indexExists(indexName);
//Verify
verifyAll();
assertEquals(exists, result);
}
示例3: call
import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequestBuilder; //导入依赖的package包/类
@Override
public Observable<Boolean> call(String index) {
Elasticsearch elasticsearch = vertxContext.verticle().elasticsearch();
IndicesExistsRequestBuilder request = elasticsearch.get().admin().indices().prepareExists(index);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(format("Request %s", Jsonify.toString(request)));
}
return elasticsearch.execute(vertxContext, request, elasticsearch.getDefaultAdminTimeout())
.map(Optional::get)
.doOnNext(indicesExistsResponse -> {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(format("Response %s", Jsonify.toString(indicesExistsResponse)));
}
})
.map(IndicesExistsResponse::isExists);
}
示例4: getCount
import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequestBuilder; //导入依赖的package包/类
@Override
public long getCount() {
long count = 0;
IndicesAdminClient admin = elastic.getClient().admin().indices();
IndicesExistsRequestBuilder builder = admin.prepareExists(config.getMisc().getDindex().getName());
if (builder.execute().actionGet().isExists()) {
SearchResponse countResponse = elastic.getClient().prepareSearch(config.getMisc().getDindex().getName())
.setTypes(config.getMisc().getCtype().getName())
.setSearchType(SearchType.QUERY_THEN_FETCH)
.setSize(0)
.execute().actionGet();
count = countResponse.getHits().getTotalHits();
} else {
logger.info("Index/Type does not exist or does not contain the record");
System.exit(-1);
}
logger.info("Elastic Index/Type count: " + count);
return count;
}
示例5: indexExists
import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequestBuilder; //导入依赖的package包/类
public boolean indexExists(final String index) {
LOGGER.trace("Checking for existance of index '{}'", index);
IndicesExistsRequestBuilder builder = client.admin().indices().prepareExists(index);
addCommonHeaders(builder);
IndicesExistsResponse response = builder.get();
boolean exists = response.isExists();
LOGGER.trace("Index '{}' exists? {}", index, exists);
return exists;
}
示例6: dropDataSet
import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequestBuilder; //导入依赖的package包/类
@Override
public void dropDataSet() {
final String indexName = config.getMisc().getDindex().getAs();
IndicesAdminClient admin = client.getClient().admin().indices();
IndicesExistsRequestBuilder builder = admin.prepareExists(indexName);
if (builder.execute().actionGet().isExists()) {
DeleteIndexResponse delete = admin.delete(new DeleteIndexRequest(indexName)).actionGet();
if (delete.isAcknowledged())
logger.info(String.format("The current index %s was deleted.", indexName));
else
logger.info(String.format("The current index %s was not deleted.", indexName));
}
}
示例7: getCount
import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequestBuilder; //导入依赖的package包/类
public long getCount(ElasticConfiguration elastic, YamlConfiguration config) {
IndicesAdminClient admin = elastic.getClient().admin().indices();
IndicesExistsRequestBuilder builder = admin.prepareExists(config.getMisc().getDindex().getAs());
assertThat(builder.execute().actionGet().isExists(), is(true));
elastic.getClient().admin().indices().flush(new FlushRequest(config.getMisc().getDindex().getAs())).actionGet();
SearchResponse response = elastic.getClient().prepareSearch(config.getMisc().getDindex().getAs())
.setTypes(config.getMisc().getCtype().getAs())
.setSearchType(SearchType.QUERY_THEN_FETCH)
.setSize(0)
.execute().actionGet();
long count = response.getHits().getTotalHits();
return count;
}
示例8: isExists
import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequestBuilder; //导入依赖的package包/类
/**
* Checks if is exists.
*
* @param index
* the index
* @return true, if is exists
*/
public boolean isExists(String index) {
IndicesExistsRequestBuilder indicesExistsRequestBuilder =
admin().indices().prepareExists(index);
return JMElastricsearchUtil
.logExcuteAndReturn("isExists", indicesExistsRequestBuilder,
indicesExistsRequestBuilder.execute())
.isExists();
}
示例9: indexExists
import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequestBuilder; //导入依赖的package包/类
/**
* Checks if a given index exists in elastic
* <p/>
* @param client
* @param indexName
* @return
*/
private boolean indexExists(Client client, String indexName) {
AdminClient admin = client.admin();
IndicesAdminClient indices = admin.indices();
IndicesExistsRequestBuilder indicesExistsRequestBuilder = indices.
prepareExists(indexName);
IndicesExistsResponse response = indicesExistsRequestBuilder
.execute()
.actionGet();
return response.isExists();
}
示例10: indexExists
import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequestBuilder; //导入依赖的package包/类
public boolean indexExists(final String index,
final BuilderCallback<IndicesExistsRequestBuilder> builder) {
final IndicesExistsResponse actionGet = builder
.apply(client().admin().indices().prepareExists(index))
.execute().actionGet();
return actionGet.isExists();
}
示例11: indexesExist
import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequestBuilder; //导入依赖的package包/类
private boolean indexesExist(List<Index> indexes)
{
if (LOG.isTraceEnabled())
{
LOG.trace("Determining index(es) '{}' existence ...", toString(indexes));
}
String[] indexNames = toIndexNames(indexes);
IndicesExistsRequestBuilder indicesExistsRequest = client.admin().indices().prepareExists(indexNames);
IndicesExistsResponse indicesExistsResponse;
try
{
indicesExistsResponse = indicesExistsRequest.get();
}
catch (ElasticsearchException e)
{
LOG.error("", e);
throw new IndexException(format("Error determining index(es) '%s' existence.", toString(indexes)));
}
boolean exists = indicesExistsResponse.isExists();
if (LOG.isDebugEnabled())
{
LOG.debug("Determined index(es) '{}' existence: {}.", toString(indexes), exists);
}
return exists;
}
示例12: prepareExists
import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequestBuilder; //导入依赖的package包/类
IndicesExistsRequestBuilder prepareExists() {
return client.admin().indices().prepareExists(getIndexName());
}
示例13: prepareExists
import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequestBuilder; //导入依赖的package包/类
@Override
public IndicesExistsRequestBuilder prepareExists(String... indices) {
return new IndicesExistsRequestBuilder(this, IndicesExistsAction.INSTANCE, indices);
}
示例14: prepareExists
import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequestBuilder; //导入依赖的package包/类
default IndicesExistsRequestBuilder prepareExists() {
return getClient().admin().indices().prepareExists(getName());
}
示例15: exists
import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequestBuilder; //导入依赖的package包/类
@Override
protected boolean exists(String indexName) {
final IndicesExistsRequestBuilder indicesExists = client.admin().indices().prepareExists(indexName);
IndicesExistsResponse indicesExistsResponse = indicesExists.execute().actionGet();
return indicesExistsResponse.isExists();
}