Java Code Examples for org.elasticsearch.client.indices.CreateIndexResponse#isAcknowledged()
The following examples show how to use
org.elasticsearch.client.indices.CreateIndexResponse#isAcknowledged() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FactSearchManager.java From act-platform with ISC License | 6 votes |
private void createIndex() { CreateIndexResponse response; try (InputStream payload = FactSearchManager.class.getClassLoader().getResourceAsStream(MAPPINGS_JSON); InputStreamReader reader = new InputStreamReader(payload)) { CreateIndexRequest request = new CreateIndexRequest(INDEX_NAME) .source(CharStreams.toString(reader), XContentType.JSON); response = clientFactory.getClient().indices().create(request, RequestOptions.DEFAULT); } catch (ElasticsearchException | IOException ex) { throw logAndExit(ex, "Could not perform request to create index."); } if (!response.isAcknowledged()) { String msg = String.format("Could not create index '%s'.", INDEX_NAME); LOGGER.error(msg); throw new IllegalStateException(msg); } LOGGER.info("Successfully created index '%s'.", INDEX_NAME); }
Example 2
Source File: ElasticSearch7Client.java From skywalking with Apache License 2.0 | 5 votes |
public boolean createIndex(String indexName) throws IOException { indexName = formatIndexName(indexName); CreateIndexRequest request = new CreateIndexRequest(indexName); CreateIndexResponse response = client.indices().create(request, RequestOptions.DEFAULT); log.debug("create {} index finished, isAcknowledged: {}", indexName, response.isAcknowledged()); return response.isAcknowledged(); }
Example 3
Source File: ElasticSearch7Client.java From skywalking with Apache License 2.0 | 5 votes |
public boolean createIndex(String indexName, Map<String, Object> settings, Map<String, Object> mapping) throws IOException { indexName = formatIndexName(indexName); CreateIndexRequest request = new CreateIndexRequest(indexName); request.settings(settings); request.mapping(mapping); CreateIndexResponse response = client.indices().create(request, RequestOptions.DEFAULT); log.debug("create {} index finished, isAcknowledged: {}", indexName, response.isAcknowledged()); return response.isAcknowledged(); }
Example 4
Source File: CaseController.java From skywalking with Apache License 2.0 | 5 votes |
private void createIndex(String indexName) throws IOException { CreateIndexRequest request = new CreateIndexRequest(indexName); XContentBuilder builder = XContentFactory.jsonBuilder(); builder.startObject(); { builder.startObject("properties"); { builder.startObject("author"); { builder.field("type", "keyword"); } builder.endObject(); builder.startObject("title"); { builder.field("type", "keyword"); } builder.endObject(); } builder.endObject(); } builder.endObject(); request.mapping(builder); request.settings(Settings.builder().put("index.number_of_shards", 1).put("index.number_of_replicas", 0)); CreateIndexResponse createIndexResponse = client.indices().create(request, RequestOptions.DEFAULT); if (createIndexResponse.isAcknowledged() == false) { String message = "elasticsearch create index fail."; logger.error(message); throw new RuntimeException(message); } }
Example 5
Source File: RestHighLevelClientCase.java From skywalking with Apache License 2.0 | 5 votes |
private void createIndex(RestHighLevelClient client, String indexName) throws IOException { CreateIndexRequest request = new CreateIndexRequest(indexName); XContentBuilder builder = XContentFactory.jsonBuilder(); builder.startObject(); { builder.startObject("properties"); { builder.startObject("author"); { builder.field("type", "keyword"); } builder.endObject(); builder.startObject("title"); { builder.field("type", "keyword"); } builder.endObject(); } builder.endObject(); } builder.endObject(); request.mapping(builder); request.settings(Settings.builder().put("index.number_of_shards", 1).put("index.number_of_replicas", 0)); CreateIndexResponse createIndexResponse = client.indices().create(request, RequestOptions.DEFAULT); if (createIndexResponse.isAcknowledged() == false) { String message = "elasticsearch create index fail."; logger.error(message); throw new RuntimeException(message); } }