Skip to content

Commit 8fe5420

Browse files
authored
Merge pull request JanusGraph#289 from sjudeng/no-es
Remove core Elasticsearch dependency
2 parents 1eb4a57 + 0afb446 commit 8fe5420

32 files changed

Lines changed: 671 additions & 824 deletions

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ env:
2424
- MODULE='solr'
2525
- MODULE='es'
2626
- MODULE='es' ARGS='-Pelasticsearch2'
27-
- MODULE='es' ARGS='-Pelasticsearch2 -Dtest=**/Transport*'
2827
- MODULE='berkeleyje'
2928
- MODULE='test'
3029
- MODULE='cassandra' ARGS='-Dtest=**/diskstorage/cassandra/thrift/* -Dtest.skip.unordered=true -Dtest.skip.ssl=true -Dtest.skip.serial=true'

docs/elasticsearch.txt

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ JanusGraph supports https://www.elastic.co/[Elasticsearch] as an index backend.
99
* *Full-Text*: Supports all `Text` predicates to search for text properties that matches a given word, prefix or regular expression.
1010
* *Geo*: Supports all `Geo` predicates to search for geo properties that are intersecting, within, disjoint to or contained in a given query geometry. Supports points, circles, boxes, lines and polygons for indexing. Supports circles, boxes and polygons for querying point properties and all shapes for querying non-point properties. Note that JTS is required when using line and polygon shapes (see <<search-predicates#geoshape,Geoshape documentation>> for more information).
1111
* *Numeric Range*: Supports all numeric comparisons in `Compare`.
12-
* *Flexible Configuration*: Supports embedded or remote operation, custom transport and discovery, and open-ended settings customization.
12+
* *Flexible Configuration*: Supports remote operation and open-ended settings customization.
1313
* *TTL*: Supports automatically expiring indexed elements.
1414
* *Collections*: Supports indexing SET and LIST cardinality properties.
1515
* *Temporal*: Nanosecond granularity temporal indexing.
@@ -38,7 +38,7 @@ For security reasons Elasticsearch must be run under a non-root account
3838

3939
=== Elasticsearch Configuration Overview
4040

41-
JanusGraph supports HTTP and Transport client connections to a running Elasticsearch cluster. Please see <<version-compat>> for details on what versions of ES will work with the different client types in JanusGraph.
41+
JanusGraph supports HTTP client connections to a running Elasticsearch cluster. Please see <<version-compat>> for details on what versions of ES will work with the different client types in JanusGraph.
4242

4343
[NOTE]
4444
JanusGraph's index options start with the string "`index.[X].`" where "`[X]`" is a user-defined name for the backend. This user-defined name must be passed to JanusGraph's ManagementSystem interface when building a mixed index, as described in <<index-mixed>>, so that JanusGraph knows which of potentially multiple configured index backends to use. Configuration snippets in this chapter use the name `search`, whereas prose discussion of options typically write `[X]` in the same position. The exact index name is not significant as long as it is used consistently in JanusGraph's configuration and when administering indices.
@@ -52,35 +52,23 @@ The Elasticsearch client is specified as follows:
5252

5353
[source, properties]
5454
----
55-
# ES REST client
56-
index.search.elasticsearch.interface=REST_CLIENT
5755
index.search.backend=elasticsearch
5856
----
5957

60-
[source, properties]
61-
----
62-
# ES TransportClient
63-
index.search.elasticsearch.interface=TRANSPORT_CLIENT
64-
index.search.backend=elasticsearch
65-
----
66-
67-
The `REST_CLIENT` and `TRANSPORT_CLIENT` values tell JanusGraph to use either the REST or Transport client, respectively. One or the other must be specified. Do not specify both in the same configuration.
6858

6959
When connecting to Elasticsearch a single or list of hostnames for the Elasticsearch instances must be provided. These are supplied via JanusGraph's `index.[X].hostname` key.
7060

7161
[source, properties]
7262
----
7363
index.search.backend=elasticsearch
74-
index.search.elasticsearch.interface=TRANSPORT_CLIENT
75-
index.search.hostname=10.0.0.10:9300
64+
index.search.hostname=10.0.0.10:9200
7665
----
7766

7867
Each host or host:port pair specified here will be added to the HTTP client's round-robin list of request targets. Here's a minimal configuration that will round-robin over 10.0.0.10 on the default Elasticsearch HTTP port (9200) and 10.0.0.20 on port 7777:
7968

8069
[source, properties]
8170
----
8271
index.search.backend=elasticsearch
83-
index.search.elasticsearch.interface=REST_CLIENT
8472
index.search.hostname=10.0.0.10, 10.0.0.20:7777
8573
----
8674

@@ -111,10 +99,6 @@ After processing `ext`, JanusGraph checks for the following common options. Jan
11199

112100
The REST client accepts the `index.[X].bulk-refresh` option. This option controls when changes are made visible to search. See https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-refresh.html[?refresh documentation] for more information. This this can also be set through the `ext` mechanism.
113101

114-
[[es-cfg-transport-opts]]
115-
==== Transport Client Options
116-
117-
The Transport client accepts the `index.[X].client-sniff` option. This can be set just as effectively through the `ext` mechanism. However, it can also be controlled through this JanusGraph config option. This option exists for continuity with the legacy config.
118102

119103
=== Secure Elasticsearch
120104

@@ -125,8 +109,8 @@ Elasticsearch does not perform authentication or authorization. A client that c
125109

126110
A client uses either one protocol/port or the other, but not both simultaneously. Securing the HTTP protocol port is generally done with a combination of firewalling and a reverse proxy with SSL encryption and HTTP authentication. There are a couple of ways to approach security on the native "transport" protocol port:
127111

128-
Tunnel ES's native "transport" protocol:: This approach can be implemented with SSL/TLS tunneling (for instance via https://www.stunnel.org/index.html[stunnel]), a VPN, or SSH port forwarding. SSL/TLS tunnels require non-trivial setup and monitoring: one or both ends of the tunnel need a certificate, and the stunnel processes need to be configured and running continuously in order for JanusGraph and Elasticsearch to communicate. The setup for most secure VPNs is likewise non-trivial. Some Elasticsearch service providers handle server-side tunnel management and provide a custom Elasticsearch `transport.type` to simplify the client setup. JanusGraph is compatible with these custom transports. See <<es-cfg-common-opts>> for information on how to override the `transport.type` and provide arbitrary `transport.*` config keys to JanusGraph's ES client.
129-
Add a firewall rule that allows only trusted clients to connect on Elasticsearch's native protocol port:: This is typically done at the host firewall level. This doesn't require any configuration changes in JanusGraph or Elasticsearch, nor does it require helper processes like stunnel. Easy to configure, but very weak security by itself.
112+
Tunnel ES's native "transport" protocol:: This approach can be implemented with SSL/TLS tunneling (for instance via https://www.stunnel.org/index.html[stunnel]), a VPN, or SSH port forwarding. SSL/TLS tunnels require non-trivial setup and monitoring: one or both ends of the tunnel need a certificate, and the stunnel processes need to be configured and running continuously. The setup for most secure VPNs is likewise non-trivial. Some Elasticsearch service providers handle server-side tunnel management and provide a custom Elasticsearch `transport.type` to simplify the client setup.
113+
Add a firewall rule that allows only trusted clients to connect on Elasticsearch's native protocol port:: This is typically done at the host firewall level. Easy to configure, but very weak security by itself.
130114

131115
[[es-cfg-index-create]]
132116
=== Index Creation Options
@@ -171,14 +155,7 @@ The `create.ext` mechanism for specifying index creation settings is compatible
171155

172156
==== Connection Issues to remote Elasticsearch cluster
173157

174-
Check that the Elasticsearch cluster nodes are reachable on the HTTP and native "transport" protocol ports from the JanusGraph nodes. Check the node listen port by examining the Elasticsearch node configuration logs or using a general diagnostic utility like `netstat`. Check the JanusGraph configuration. Disable sniffing to restrict the Transport client to just the configured host list. Check that the client and server have the same major version: 1.x and 2.x are not compatible.
175-
176-
==== Classpath or Field errors
177-
178-
When you see exception referring to lucene implementation details, make sure you don't have a conflicting version of Lucene on the classpath. Exception may look like this:
179-
180-
[source, text]
181-
java.lang.NoSuchFieldError: LUCENE_5_5_2
158+
Check that the Elasticsearch cluster nodes are reachable on the HTTP protocol port from the JanusGraph nodes. Check the node listen port by examining the Elasticsearch node configuration logs or using a general diagnostic utility like `netstat`. Check the JanusGraph configuration.
182159

183160
=== Optimizing Elasticsearch
184161

@@ -190,4 +167,4 @@ For additional suggestions on how to increase write performance in Elasticsearch
190167

191168
==== Further Reading
192169

193-
* Please refer to the https://www.elastic.co[Elasticsearch homepage] and available documentation for more information on Elasticsearch and how to setup an Elasticsearch cluster.
170+
* Please refer to the https://www.elastic.co[Elasticsearch homepage] and available documentation for more information on Elasticsearch and how to setup an Elasticsearch cluster.

docs/versions.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ JanusGraph.
1313
[options="header"]
1414
|==========================
1515
| JanusGraph | Cassandra | HBase | Bigtable | Elasticsearch | Solr | TinkerPop
16-
| 0.1.0 | 1.2.z, 2.0.z, 2.1.z | 0.98.z, 1.0.z, 1.1.z, 1.2.z | 0.9.z | 2.z,5.z* | 5.2.z | 3.2.z |
16+
| 0.1.0 | 1.2.z, 2.0.z, 2.1.z | 0.98.z, 1.0.z, 1.1.z, 1.2.z | 0.9.z | 1.z*,2.z,5.z | 5.2.z | 3.2.z |
1717
|==========================
1818

19-
*The Elasticsearch REST client is compatible with both Elasticsearch 2.z and 5.z. The transport client is only compatibile with Elasticsearch 2.z.
19+
*Elasticsearch 1.z compatibility is deprecated and no longer tested by default

janusgraph-core/src/main/java/org/janusgraph/diskstorage/indexing/IndexFeatures.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,12 @@ public class IndexFeatures {
3636
private final String wildcardField;
3737
private final boolean supportsNanoseconds;
3838
private final boolean supportsCustomAnalyzer;
39+
private final boolean supportsGeoContains;
3940
private ImmutableSet<Cardinality> supportedCardinalities;
4041

41-
public IndexFeatures(boolean supportsDocumentTTL,
42-
Mapping defaultMap,
43-
ImmutableSet<Mapping> supportedMap, String wildcardField, ImmutableSet<Cardinality> supportedCardinaities, boolean supportsNanoseconds, boolean supportCustomAnalyzer) {
42+
public IndexFeatures(boolean supportsDocumentTTL, Mapping defaultMap, ImmutableSet<Mapping> supportedMap,
43+
String wildcardField, ImmutableSet<Cardinality> supportedCardinaities, boolean supportsNanoseconds,
44+
boolean supportCustomAnalyzer, boolean supportsGeoContains) {
4445

4546
Preconditions.checkArgument(defaultMap!=null || defaultMap!=Mapping.DEFAULT);
4647
Preconditions.checkArgument(supportedMap!=null && !supportedMap.isEmpty()
@@ -52,6 +53,7 @@ public IndexFeatures(boolean supportsDocumentTTL,
5253
this.supportedCardinalities = supportedCardinaities;
5354
this.supportsNanoseconds = supportsNanoseconds;
5455
this.supportsCustomAnalyzer = supportCustomAnalyzer;
56+
this.supportsGeoContains = supportsGeoContains;
5557
}
5658

5759
public boolean supportsDocumentTTL() {
@@ -82,6 +84,10 @@ public boolean supportsCustomAnalyzer() {
8284
return supportsCustomAnalyzer;
8385
}
8486

87+
public boolean supportsGeoContains() {
88+
return supportsGeoContains;
89+
}
90+
8591
public static class Builder {
8692

8793
private boolean supportsDocumentTTL = false;
@@ -91,6 +97,7 @@ public static class Builder {
9197
private String wildcardField = "*";
9298
private boolean supportsNanoseconds;
9399
private boolean supportsCustomAnalyzer;
100+
private boolean supportsGeoContains = false;
94101

95102
public Builder supportsDocumentTTL() {
96103
supportsDocumentTTL=true;
@@ -127,9 +134,15 @@ public Builder supportsCustomAnalyzer() {
127134
return this;
128135
}
129136

137+
public Builder supportsGeoContains() {
138+
this.supportsGeoContains = true;
139+
return this;
140+
}
141+
130142
public IndexFeatures build() {
131-
return new IndexFeatures(supportsDocumentTTL, defaultStringMapping,
132-
ImmutableSet.copyOf(supportedMappings), wildcardField, ImmutableSet.copyOf(supportedCardinalities), supportsNanoseconds, supportsCustomAnalyzer);
143+
return new IndexFeatures(supportsDocumentTTL, defaultStringMapping, ImmutableSet.copyOf(supportedMappings),
144+
wildcardField, ImmutableSet.copyOf(supportedCardinalities), supportsNanoseconds, supportsCustomAnalyzer,
145+
supportsGeoContains);
133146
}
134147

135148

janusgraph-es/pom.xml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,6 @@
5050
<version>${project.version}</version>
5151
<scope>test</scope>
5252
</dependency>
53-
<dependency>
54-
<groupId>org.elasticsearch</groupId>
55-
<artifactId>elasticsearch</artifactId>
56-
<version>${elasticsearch.version}</version>
57-
</dependency>
5853
<dependency>
5954
<groupId>org.elasticsearch.client</groupId>
6055
<artifactId>rest</artifactId>
@@ -219,9 +214,6 @@
219214
<id>default-test</id>
220215
<configuration>
221216
<argLine>${default.test.jvm.opts} -Dtest.cassandra.confdir=${project.build.directory}/cassandra/conf/localhost-murmur -Dtest.cassandra.datadir=${project.build.directory}/cassandra/data/localhost-murmur</argLine>
222-
<excludes>
223-
<exclude>**/Transport*.java</exclude>
224-
</excludes>
225217
</configuration>
226218
</execution>
227219

@@ -261,7 +253,7 @@
261253
<profile>
262254
<id>elasticsearch2</id>
263255
<properties>
264-
<elasticsearch.dist.version>${elasticsearch.version}</elasticsearch.dist.version>
256+
<elasticsearch.dist.version>2.4.4</elasticsearch.dist.version>
265257
<elasticsearch.groovy.inline>true</elasticsearch.groovy.inline>
266258
</properties>
267259
</profile>

janusgraph-es/src/main/java/org/janusgraph/diskstorage/es/ElasticMajorVersion.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@
1616

1717
public enum ElasticMajorVersion {
1818

19+
ONE,
20+
1921
TWO,
2022

21-
FIVE
23+
FIVE,
24+
25+
;
2226

2327
}

janusgraph-es/src/main/java/org/janusgraph/diskstorage/es/ElasticSearchClient.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414

1515
package org.janusgraph.diskstorage.es;
1616

17-
import org.elasticsearch.common.settings.Settings;
18-
import org.elasticsearch.common.xcontent.XContentBuilder;
19-
2017
import java.io.Closeable;
2118
import java.io.IOException;
2219
import java.util.List;
@@ -30,18 +27,18 @@ public interface ElasticSearchClient extends Closeable {
3027

3128
boolean indexExists(String indexName) throws IOException;
3229

33-
void createIndex(String indexName, Settings settings) throws IOException;
30+
void createIndex(String indexName, Map<String,Object> settings) throws IOException;
3431

3532
Map getIndexSettings(String indexName) throws IOException;
3633

37-
void createMapping(String indexName, String typeName, XContentBuilder mapping) throws IOException;
34+
void createMapping(String indexName, String typeName, Map<String,Object> mapping) throws IOException;
3835

3936
Map getMapping(String indexName, String typeName) throws IOException;
4037

4138
void deleteIndex(String indexName) throws IOException;
4239

4340
void bulkRequest(List<ElasticSearchMutation> requests) throws IOException;
4441

45-
ElasticSearchResponse search(String indexName, String type, ElasticSearchRequest request) throws IOException;
42+
ElasticSearchResponse search(String indexName, String type, Map<String,Object> request) throws IOException;
4643

4744
}

janusgraph-es/src/main/java/org/janusgraph/diskstorage/es/ElasticSearchConstants.java

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,8 @@ public class ElasticSearchConstants {
3232
public static final String ES_SCRIPT_KEY = "script";
3333
public static final String ES_INLINE_KEY = "inline";
3434
public static final String ES_LANG_KEY = "lang";
35-
public static final String ES_VERSION_EXPECTED;
36-
37-
static {
38-
Properties props;
39-
40-
try {
41-
props = new Properties();
42-
props.load(JanusGraphFactory.class.getClassLoader().getResourceAsStream(ES_PROPERTIES_FILE));
43-
} catch (IOException e) {
44-
throw new AssertionError(e);
45-
}
46-
47-
ES_VERSION_EXPECTED = props.getProperty("es.version");
48-
}
35+
public static final String ES_TYPE_KEY = "type";
36+
public static final String ES_INDEX_KEY = "index";
37+
public static final String ES_ANALYZER = "analyzer";
38+
public static final String ES_GEO_COORDS_KEY = "coordinates";
4939
}

0 commit comments

Comments
 (0)