Skip to content

Commit

Permalink
[NOID] cleanup and fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vga91 committed Dec 16, 2024
1 parent 9b13481 commit 1a3e3c3
Show file tree
Hide file tree
Showing 9 changed files with 594 additions and 1,011 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ include::example$generated-documentation/apoc.es.delete.adoc[]

[NOTE]
====
It is currently not possible to query Elastic 8 via certificate,
It is currently not possible to query Elastic 8 via certificate,
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)
or (not recommended) disabling security via `xpack.security.enabled=false`
====
Expand Down Expand Up @@ -74,7 +74,7 @@ Here an example:
[source,cypher]
----
// It's important to create an index to improve performance
CREATE INDEX ON :Document(id)
CREATE INDEX FOR (n:Document) ON (n.id)
// First query: get first chunk of data + the scroll_id for pagination
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
// Do something with hits
Expand Down Expand Up @@ -108,16 +108,71 @@ call apoc.es.post(host-or-key,index-or-null,type-or-null,id-or-null,query-or-nul

=== host-or-key parameter

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

* host
* host:port
* username:password@host:port
* http://host:port
* lookup via key to apoc.es.<key>.url
* lookup via key apoc.es.<key>.host
* http://username:password@host:port

For example, by using the `apoc.es.stats`, we can execute:
[source, cypher]
----
CALL apoc.es.stats('http://username:password@host:port')
----

Moreover, it can be an entry to be lookup up in `apoc.conf`:

* lookup apoc.es.url
* lookup apoc.es.host

This takes precedence over the direct string host or url as the first parameter, as above.

For example, with a `apoc.conf` like this:
```
apoc.es.url=http://username:password@host:port
```

or like this :
```
apoc.es.host=username:password@host:port
```

we can connect to elastic by putting null as the first parameter.

For example, by using the `apoc.es.stats`, we can execute:
[source, cypher]
----
CALL apoc.es.stats(null)
----

Furthermore, it can be an entry to be lookup up in `apoc.conf`,
where `<key>` have be placed in the first parameter:

* lookup via key to apoc.es.<key>.url
* lookup via key apoc.es.<key>.host


For example, with a `apoc.conf` like this:
```
apoc.es.custom.url=http://username:password@host:port
```

or like this:
```
apoc.es.custom.host=username:password@host:port
```

we can connect to elastic by putting null as the first parameter.

For example, by using the `apoc.es.stats`, we can execute:
[source, cypher]
----
CALL apoc.es.stats('custom')
----


=== index parameter

Main ES index, will be sent directly, if null then "_all" multiple indexes can be separated by comma in the string.
Expand Down Expand Up @@ -147,10 +202,10 @@ Config can be an optional *map*, which can have the following entries:
|===
| name | type | default | description
| headers | `Map` | {`content-type`: "application/json", `method`, "<httpMethod>"} | Contains a header map to add (or replace) the default one.
The `method: <httpMethod>` is needed by APOC to figure out under the hood, which http request method to pass.
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.
| version | `String` | `DEFAULT` | Can be `DEFAULT` and `EIGHT`, in order to change the RestAPI endpoint based on Elastic version.
See `Endpoint` table below.
The `method: <httpMethod>` is needed by APOC to figure out under the hood, which http request method to pass.
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.
| version | `String` | `DEFAULT` | Can be `DEFAULT` and `EIGHT`, in order to change the RestAPI endpoint based on Elastic version.
See `Endpoint` table below.
|===


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

to use a https://www.elastic.co/guide/en/elasticsearch/reference/current/http-clients.html[Basic authentication]
to use a https://www.elastic.co/guide/en/elasticsearch/reference/current/http-clients.html[Basic authentication]
and create the following HTTP header:
```
Authorization: Basic <Base64Token>
Expand All @@ -177,12 +232,12 @@ for example the `apoc.es.query`.
.Endpoint
[opts=header]
|===
| procedure(s) | with version: `DEFAULT` | with version: `EIGHT`
| procedure(s) | with version: `DEFAULT` | with version: `EIGHT`
| `apoc.es.stats(host)` | <host>/_stats | same as `DEFAULT`
| `apoc.es.query(host, index, type, query, payload, $conf)` | <host>/<index param>/<type param>/_stats?<query param> | <host>/<index param>/_stats?<query param>
| `apoc.es.getRaw/apoc.es.postRaw(host, path, payload, $conf)` | `<host>/<path param>` | same as `DEFAULT`
| the others `apoc.es.<name>(host, index, type, id, query, payload, $conf)` procedures | `<host>/<index param>/<type param>/<id param>_stats?<query param>`
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
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
| `<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.

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]).
Expand Down Expand Up @@ -213,4 +268,4 @@ CALL apoc.es.put($host,'<indexName>', null, null, null, null, { version: 'EIGHT'

=== Results

Results are stream of map in value.
Results are stream of map in value.
1 change: 1 addition & 0 deletions full-it/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ dependencies {

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

configurations.all {
exclude group: 'org.slf4j', module: 'slf4j-nop'
Expand Down
Loading

0 comments on commit 1a3e3c3

Please sign in to comment.