gora-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (Jira)" <j...@apache.org>
Subject [jira] [Commented] (GORA-664) Add datastore for Elasticsearch
Date Fri, 14 May 2021 16:35:00 GMT

    [ https://issues.apache.org/jira/browse/GORA-664?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17344706#comment-17344706
] 

ASF GitHub Bot commented on GORA-664:
-------------------------------------

kamaci commented on a change in pull request #234:
URL: https://github.com/apache/gora/pull/234#discussion_r632653393



##########
File path: gora-elasticsearch/src/main/java/org/apache/gora/elasticsearch/store/ElasticsearchStoreMetadataAnalyzer.java
##########
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.gora.elasticsearch.store;
+
+import org.apache.gora.elasticsearch.utils.ElasticsearchParameters;
+import org.apache.gora.store.impl.DataStoreMetadataAnalyzer;
+import org.apache.gora.util.GoraException;
+import org.elasticsearch.client.RequestOptions;
+import org.elasticsearch.client.RestHighLevelClient;
+import org.elasticsearch.client.indices.GetIndexRequest;
+import org.elasticsearch.client.indices.GetIndexResponse;
+import org.elasticsearch.cluster.metadata.MappingMetadata;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+public class ElasticsearchStoreMetadataAnalyzer extends DataStoreMetadataAnalyzer {
+
+    private RestHighLevelClient elasticsearchClient;
+
+    @Override
+    public void initialize() throws GoraException {
+        ElasticsearchParameters parameters = ElasticsearchParameters.load(properties, getConf());
+        elasticsearchClient = ElasticsearchStore.createClient(parameters);
+    }
+
+    @Override
+    public String getType() {
+        return "ELASTICSEARCH";
+    }
+
+    @Override
+    public List<String> getTablesNames() throws GoraException {
+        GetIndexRequest request = new GetIndexRequest("*");
+        GetIndexResponse response;
+        try {
+            response = elasticsearchClient.indices().get(request, RequestOptions.DEFAULT);
+        } catch (IOException ex) {
+            throw new GoraException(ex);
+        }
+        assert response != null;

Review comment:
       Consider logging and throwing an error without using assert.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Add datastore for Elasticsearch
> -------------------------------
>
>                 Key: GORA-664
>                 URL: https://issues.apache.org/jira/browse/GORA-664
>             Project: Apache Gora
>          Issue Type: New Feature
>            Reporter: Carlos Muñoz
>            Assignee: Mariia Podorvanova
>            Priority: Major
>              Labels: outreachy2020
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> Elasticsearch is a Lucene-based search engine that primarily focuses on distribution
and availability. It could be a good alternative for the gora-solr module.
>  
> [https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html] 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Mime
View raw message