Skip to content

Commit 1a3e3c3

Browse files
committed
[NOID] cleanup and fix tests
1 parent 9b13481 commit 1a3e3c3

File tree

9 files changed

+594
-1011
lines changed

9 files changed

+594
-1011
lines changed

docs/asciidoc/modules/ROOT/pages/database-integration/elasticsearch.adoc

Lines changed: 68 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ include::example$generated-documentation/apoc.es.delete.adoc[]
2525

2626
[NOTE]
2727
====
28-
It is currently not possible to query Elastic 8 via certificate,
28+
It is currently not possible to query Elastic 8 via certificate,
2929
but only disabling ssl with the configuration `"xpack.security.http.ssl.enabled=false"`, using the basic authentication via the header config (see `config parameter` below)
3030
or (not recommended) disabling security via `xpack.security.enabled=false`
3131
====
@@ -74,7 +74,7 @@ Here an example:
7474
[source,cypher]
7575
----
7676
// It's important to create an index to improve performance
77-
CREATE INDEX ON :Document(id)
77+
CREATE INDEX FOR (n:Document) ON (n.id)
7878
// First query: get first chunk of data + the scroll_id for pagination
7979
CALL apoc.es.query('localhost','test-index','test-type','name:Neo4j&size=1&scroll=5m',null) yield value with value._scroll_id as scrollId, value.hits.hits as hits
8080
// Do something with hits
@@ -108,16 +108,71 @@ call apoc.es.post(host-or-key,index-or-null,type-or-null,id-or-null,query-or-nul
108108

109109
=== host-or-key parameter
110110

111-
The parameter can be a direct host or url, or an entry to be lookup up in apoc.conf
111+
The parameter can be:
112112

113113
* host
114114
* host:port
115+
* username:password@host:port
115116
* http://host:port
116-
* lookup via key to apoc.es.<key>.url
117-
* lookup via key apoc.es.<key>.host
117+
* http://username:password@host:port
118+
119+
For example, by using the `apoc.es.stats`, we can execute:
120+
[source, cypher]
121+
----
122+
CALL apoc.es.stats('http://username:password@host:port')
123+
----
124+
125+
Moreover, it can be an entry to be lookup up in `apoc.conf`:
126+
118127
* lookup apoc.es.url
119128
* lookup apoc.es.host
120129

130+
This takes precedence over the direct string host or url as the first parameter, as above.
131+
132+
For example, with a `apoc.conf` like this:
133+
```
134+
apoc.es.url=http://username:password@host:port
135+
```
136+
137+
or like this :
138+
```
139+
apoc.es.host=username:password@host:port
140+
```
141+
142+
we can connect to elastic by putting null as the first parameter.
143+
144+
For example, by using the `apoc.es.stats`, we can execute:
145+
[source, cypher]
146+
----
147+
CALL apoc.es.stats(null)
148+
----
149+
150+
Furthermore, it can be an entry to be lookup up in `apoc.conf`,
151+
where `<key>` have be placed in the first parameter:
152+
153+
* lookup via key to apoc.es.<key>.url
154+
* lookup via key apoc.es.<key>.host
155+
156+
157+
For example, with a `apoc.conf` like this:
158+
```
159+
apoc.es.custom.url=http://username:password@host:port
160+
```
161+
162+
or like this:
163+
```
164+
apoc.es.custom.host=username:password@host:port
165+
```
166+
167+
we can connect to elastic by putting null as the first parameter.
168+
169+
For example, by using the `apoc.es.stats`, we can execute:
170+
[source, cypher]
171+
----
172+
CALL apoc.es.stats('custom')
173+
----
174+
175+
121176
=== index parameter
122177

123178
Main ES index, will be sent directly, if null then "_all" multiple indexes can be separated by comma in the string.
@@ -147,10 +202,10 @@ Config can be an optional *map*, which can have the following entries:
147202
|===
148203
| name | type | default | description
149204
| headers | `Map` | {`content-type`: "application/json", `method`, "<httpMethod>"} | Contains a header map to add (or replace) the default one.
150-
The `method: <httpMethod>` is needed by APOC to figure out under the hood, which http request method to pass.
151-
That is, by default, it is `PUT` with the `apoc.es.put`, POST with the `apoc.es.post` and `apoc.es.postRaw`, and GET in other cases.
152-
| version | `String` | `DEFAULT` | Can be `DEFAULT` and `EIGHT`, in order to change the RestAPI endpoint based on Elastic version.
153-
See `Endpoint` table below.
205+
The `method: <httpMethod>` is needed by APOC to figure out under the hood, which http request method to pass.
206+
That is, by default, it is `PUT` with the `apoc.es.put`, POST with the `apoc.es.post` and `apoc.es.postRaw`, and GET in other cases.
207+
| version | `String` | `DEFAULT` | Can be `DEFAULT` and `EIGHT`, in order to change the RestAPI endpoint based on Elastic version.
208+
See `Endpoint` table below.
154209
|===
155210

156211

@@ -160,7 +215,7 @@ For example, by using the `apoc.es.stats`, we can execute:
160215
CALL apoc.es.stats('custom', { headers: {Authorization: "Basic <Base64Token>"} })
161216
----
162217

163-
to use a https://www.elastic.co/guide/en/elasticsearch/reference/current/http-clients.html[Basic authentication]
218+
to use a https://www.elastic.co/guide/en/elasticsearch/reference/current/http-clients.html[Basic authentication]
164219
and create the following HTTP header:
165220
```
166221
Authorization: Basic <Base64Token>
@@ -177,12 +232,12 @@ for example the `apoc.es.query`.
177232
.Endpoint
178233
[opts=header]
179234
|===
180-
| procedure(s) | with version: `DEFAULT` | with version: `EIGHT`
235+
| procedure(s) | with version: `DEFAULT` | with version: `EIGHT`
181236
| `apoc.es.stats(host)` | <host>/_stats | same as `DEFAULT`
182237
| `apoc.es.query(host, index, type, query, payload, $conf)` | <host>/<index param>/<type param>/_stats?<query param> | <host>/<index param>/_stats?<query param>
183238
| `apoc.es.getRaw/apoc.es.postRaw(host, path, payload, $conf)` | `<host>/<path param>` | same as `DEFAULT`
184239
| the others `apoc.es.<name>(host, index, type, id, query, payload, $conf)` procedures | `<host>/<index param>/<type param>/<id param>_stats?<query param>`
185-
By default, the `<index param>` and `<id param>` will be populated as `_all`, while the `<id param>`, if not present, will be removed from the endpoint
240+
By default, the `<index param>` and `<id param>` will be populated as `_all`, while the `<id param>`, if not present, will be removed from the endpoint
186241
| `<host>/<index param>/<type param>/<id param>_stats?<query param>`. Note that you only need to enter one of three values between `<index param>`,`<id param>` and `<type param>`, the others will eventually be excluded from the endpoint.
187242

188243
The type param is usually an underscore string indicating the type of the API, e.g. `_doc` or `_update` (while previously indicated https://www.elastic.co/guide/en/elasticsearch/reference/6.1/removal-of-types.html[the mapping types]).
@@ -213,4 +268,4 @@ CALL apoc.es.put($host,'<indexName>', null, null, null, null, { version: 'EIGHT'
213268

214269
=== Results
215270

216-
Results are stream of map in value.
271+
Results are stream of map in value.

full-it/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ dependencies {
1313

1414
testImplementation group: 'com.amazonaws', name: 'aws-java-sdk-s3', version: '1.12.770'
1515
testImplementation group: 'org.xmlunit', name: 'xmlunit-core', version: '2.9.1'
16+
testImplementation group: 'com.jayway.jsonpath', name: 'json-path', version: '2.9.0'
1617

1718
configurations.all {
1819
exclude group: 'org.slf4j', module: 'slf4j-nop'

0 commit comments

Comments
 (0)