-
Notifications
You must be signed in to change notification settings - Fork 434
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #169 from rayokota/4.0.x
CC-1385: Enhance connector to use text type with ES 5+
- Loading branch information
Showing
16 changed files
with
945 additions
and
268 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
src/main/java/io/confluent/connect/elasticsearch/ElasticsearchClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/** | ||
* Copyright 2018 Confluent Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
**/ | ||
|
||
package io.confluent.connect.elasticsearch; | ||
|
||
import com.google.gson.JsonObject; | ||
import io.confluent.connect.elasticsearch.bulk.BulkRequest; | ||
import io.confluent.connect.elasticsearch.bulk.BulkResponse; | ||
import org.apache.kafka.connect.data.Schema; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
public interface ElasticsearchClient extends AutoCloseable { | ||
|
||
enum Version { | ||
ES_V1, ES_V2, ES_V5, ES_V6 | ||
} | ||
|
||
/** | ||
* Gets the Elasticsearch version. | ||
* | ||
* @return the version, not null | ||
*/ | ||
Version getVersion(); | ||
|
||
/** | ||
* Creates indices. | ||
* | ||
* @param indices the set of index names to create, not null | ||
*/ | ||
void createIndices(Set<String> indices); | ||
|
||
/** | ||
* Creates an explicit mapping. | ||
* | ||
* @param index the index to write | ||
* @param type the type for which to create the mapping | ||
* @param schema the schema used to infer the mapping | ||
* @throws IOException if the client cannot execute the request | ||
*/ | ||
void createMapping(String index, String type, Schema schema) throws IOException; | ||
|
||
/** | ||
* Gets the JSON mapping for the given index and type. Returns {@code null} if it does not exist. | ||
* | ||
* @param index the index | ||
* @param type the type | ||
* @throws IOException if the client cannot execute the request | ||
*/ | ||
JsonObject getMapping(String index, String type) throws IOException; | ||
|
||
/** | ||
* Creates a bulk request for the list of {@link IndexableRecord} records. | ||
* | ||
* @param batch the list of records | ||
* @return the bulk request | ||
*/ | ||
BulkRequest createBulkRequest(List<IndexableRecord> batch); | ||
|
||
/** | ||
* Executes a bulk action. | ||
* | ||
* @param bulk the bulk request | ||
* @return the bulk response | ||
* @throws IOException if the client cannot execute the request | ||
*/ | ||
BulkResponse executeBulk(BulkRequest bulk) throws IOException; | ||
|
||
/** | ||
* Executes a search. | ||
* | ||
* @param query the search query | ||
* @param index the index to search | ||
* @param type the type to search | ||
* @return the search result | ||
* @throws IOException if the client cannot execute the request | ||
*/ | ||
JsonObject search(String query, String index, String type) throws IOException; | ||
|
||
/** | ||
* Shuts down the client. | ||
*/ | ||
void close(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.