Skip to content

Commit

Permalink
Remove index.type parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
dilini-muthumala committed Jun 18, 2019
1 parent c977d19 commit 5e8e53f
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@
ANNOTATION_ELEMENT_INDEX_NUMBER_OF_REPLICAS;
import static org.wso2.extension.siddhi.store.elasticsearch.utils.ElasticsearchTableConstants.
ANNOTATION_ELEMENT_INDEX_NUMBER_OF_SHARDS;
import static org.wso2.extension.siddhi.store.elasticsearch.utils.ElasticsearchTableConstants.
ANNOTATION_ELEMENT_INDEX_TYPE;
import static org.wso2.extension.siddhi.store.elasticsearch.utils.ElasticsearchTableConstants.
ANNOTATION_ELEMENT_MEMBER_LIST;
import static org.wso2.extension.siddhi.store.elasticsearch.utils.ElasticsearchTableConstants.
Expand Down Expand Up @@ -140,7 +138,6 @@
DEFAULT_CONCURRENT_REQUESTS;
import static org.wso2.extension.siddhi.store.elasticsearch.utils.ElasticsearchTableConstants.DEFAULT_FLUSH_INTERVAL;
import static org.wso2.extension.siddhi.store.elasticsearch.utils.ElasticsearchTableConstants.DEFAULT_HOSTNAME;
import static org.wso2.extension.siddhi.store.elasticsearch.utils.ElasticsearchTableConstants.DEFAULT_INDEX_TYPE;
import static org.wso2.extension.siddhi.store.elasticsearch.utils.ElasticsearchTableConstants.DEFAULT_IO_THREAD_COUNT;
import static org.wso2.extension.siddhi.store.elasticsearch.utils.ElasticsearchTableConstants.
DEFAULT_NUMBER_OF_REPLICAS;
Expand Down Expand Up @@ -198,9 +195,6 @@
description = "The name of the Elasticsearch index.",
type = {DataType.STRING}, optional = true,
defaultValue = "The table name defined in the Siddhi App query."),
@Parameter(name = "index.type",
description = "The the type of the index.",
type = {DataType.STRING}, optional = true, defaultValue = "null"),
@Parameter(name = "payload.index.of.index.name",
description = "The payload which is used to create the index. This can be used if the user " +
"needs to create index names dynamically",
Expand Down Expand Up @@ -312,7 +306,6 @@ public class ElasticsearchEventTable extends AbstractRecordTable {
private List<String> primaryKeys;
private String hostname = DEFAULT_HOSTNAME;
private String indexName;
private String indexType = DEFAULT_INDEX_TYPE;
private String indexAlias;
private int port = DEFAULT_PORT;
private String scheme = DEFAULT_SCHEME;
Expand Down Expand Up @@ -369,7 +362,6 @@ protected void init(TableDefinition tableDefinition, ConfigReader configReader)
} else {
port = Integer.parseInt(configReader.readConfig(ANNOTATION_ELEMENT_HOSTNAME, String.valueOf(port)));
}
indexType = storeAnnotation.getElement(ANNOTATION_ELEMENT_INDEX_TYPE);
if (!ElasticsearchTableUtils.isEmpty(storeAnnotation.
getElement(ANNOTATION_ELEMENT_INDEX_NUMBER_OF_SHARDS))) {
numberOfShards = Integer.parseInt(storeAnnotation.getElement(
Expand Down Expand Up @@ -657,11 +649,7 @@ private ElasticsearchRecordIterator findRecords(Map<String, Object> findConditio
compiledCondition) throws ElasticsearchServiceException {
String condition = ElasticsearchTableUtils.resolveCondition((ElasticsearchCompiledCondition) compiledCondition,
findConditionParameterMap);
if (indexType != null) {
return new ElasticsearchRecordIterator(indexName, condition, restHighLevelClient, attributes);
} else {
return new ElasticsearchRecordIterator(indexName, indexType, condition, restHighLevelClient, attributes);
}
return new ElasticsearchRecordIterator(indexName, condition, restHighLevelClient, attributes);
}

/**.
Expand Down Expand Up @@ -868,9 +856,6 @@ private void createIndex() {
XContentBuilder builder = XContentFactory.jsonBuilder();
builder.startObject();
{
if (indexType != null) {
builder.startObject(indexType);
}
builder.startObject(MAPPING_PROPERTIES_ELEMENT);
{
for (Attribute attribute : attributes) {
Expand Down Expand Up @@ -908,9 +893,6 @@ private void createIndex() {
}
}
builder.endObject();
if (indexType != null) {
builder.endObject();
}
}
builder.endObject();
request.mapping(builder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,6 @@ public class ElasticsearchRecordIterator implements RecordIterator<Object[]> {
private List<Attribute> attributes;
private Iterator<SearchHit> elasticsearchHitsIterator;

public ElasticsearchRecordIterator(String indexName, String indexType, String queryString,
RestHighLevelClient restHighLevelClient, List<Attribute> attributes)
throws ElasticsearchServiceException {
this.attributes = attributes;
QueryBuilder queryBuilder = getQueryBuilder(queryString);
SearchRequest searchRequest = new SearchRequest(indexName);
searchRequest.types(indexType);
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.query(queryBuilder);
searchRequest.source(searchSourceBuilder);
try {
SearchResponse searchResponse = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT);
elasticsearchHitsIterator = searchResponse.getHits().iterator();
} catch (IOException e) {
throw new ElasticsearchServiceException("Error while performing search the query: '" + queryString + "'",
e);
}
}

public ElasticsearchRecordIterator(String indexName, String queryString,
RestHighLevelClient restHighLevelClient, List<Attribute> attributes)
throws ElasticsearchServiceException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public class ElasticsearchTableConstants {
public static final String ANNOTATION_ELEMENT_INDEX_NUMBER_OF_SHARDS = "index.number.of.shards";
public static final String ANNOTATION_ELEMENT_INDEX_NUMBER_OF_REPLICAS = "index.number.of.replicas";
public static final String ANNOTATION_ELEMENT_INDEX_ALIAS = "index.alias";
public static final String ANNOTATION_ELEMENT_INDEX_TYPE = "index.type";
public static final String ANNOTATION_ELEMENT_UPDATE_BATCH_SIZE = "update.batch.size";
public static final String ANNOTATION_ELEMENT_BULK_ACTIONS = "bulk.actions";
public static final String ANNOTATION_ELEMENT_BULK_SIZE = "bulk.size";
Expand All @@ -50,7 +49,6 @@ public class ElasticsearchTableConstants {
public static final String ANNOTATION_TYPE_MAPPINGS = "TypeMappings";

public static final String DEFAULT_HOSTNAME = "localhost";
public static final String DEFAULT_INDEX_TYPE = "_doc";
public static final int DEFAULT_PORT = 9200;
public static final int DEFAULT_NUMBER_OF_SHARDS = 3;
public static final int DEFAULT_NUMBER_OF_REPLICAS = 2;
Expand Down

0 comments on commit 5e8e53f

Please sign in to comment.