elasticsearch/docs/java-rest/high-level
Nik Everett 0d9b78834f
LLClient: Support host selection (#30523)
Allows users of the Low Level REST client to specify which hosts a
request should be run on. They implement the  `NodeSelector` interface
or reuse a built in selector like `NOT_MASTER_ONLY` to chose which nodes
are valid. Using it looks like:
```
Request request = new Request("POST", "/foo/_search");
RequestOptions options = request.getOptions().toBuilder();
options.setNodeSelector(NodeSelector.NOT_MASTER_ONLY);
request.setOptions(options);
...
```

This introduces a new `Node` object which contains a `HttpHost` and the
metadata about the host. At this point that metadata is just `version`
and `roles` but I plan to add node attributes in a followup. The
canonical way to **get** this metadata is to use the `Sniffer` to pull
the information from the Elasticsearch cluster.

I've marked this as "breaking-java" because it breaks custom
implementations of `HostsSniffer` by renaming the interface to
`NodesSniffer` and by changing it from returning a `List<HttpHost>` to a
`List<Node>`. It *shouldn't* break anyone else though.

Because we expect to find it useful, this also implements `host_selector`
support to `do` statements in the yaml tests. Using it looks a little
like:

```
---
"example test":
  - skip:
      features: host_selector
  - do:
      host_selector:
        version: " - 7.0.0" # same syntax as skip
      apiname:
        something: true
```

The `do` section parses the `version` string into a host selector that
uses the same version comparison logic as the `skip` section. When the
`do` section is executed it passed the off to the `RestClient`, using
the `ElasticsearchHostsSniffer` to sniff the required metadata.

The idea is to use this in mixed version tests to target a specific
version of Elasticsearch so we can be sure about the deprecation
logging though we don't currently have any examples that need it. We do,
however, have at least one open pull request that requires something
like this to properly test it.

Closes #21888
2018-06-11 17:07:27 -04:00
..
cluster Move pipeline APIs to ingest namespace (#31027) 2018-06-04 10:34:55 +02:00
document Docs: Fix callouts after _parent removed 2018-04-11 12:56:13 -04:00
indices HLRest: Add get index templates API (#31161) 2018-06-11 11:06:28 -04:00
ingest Move pipeline APIs to ingest namespace (#31027) 2018-06-04 10:34:55 +02:00
miscellaneous Docs: HighLevelRestClient#ping (#29070) 2018-03-14 14:27:01 -04:00
search Add support for search templates to the high-level REST client. (#30473) 2018-05-15 13:07:58 -07:00
snapshot Add Verify Repository High Level REST API (#30934) 2018-05-30 11:10:00 -05:00
tasks high level REST api: cancel task (#30745) 2018-06-07 14:02:23 -07:00
aggs-builders.asciidoc [DOCS] Update APIs grouping and ordering in REST high-level Client docs (#28497) 2018-02-02 17:19:50 +01:00
getting-started.asciidoc LLClient: Support host selection (#30523) 2018-06-11 17:07:27 -04:00
index.asciidoc [Docs] Add "Using Java Builders" section (#26517) 2017-09-06 14:06:41 +02:00
java-builders.asciidoc [DOCS] Update APIs grouping and ordering in REST high-level Client docs (#28497) 2018-02-02 17:19:50 +01:00
migration.asciidoc Docs: Update HighLevelRestClient migration docs (#30544) 2018-05-14 11:11:27 -04:00
query-builders.asciidoc added docs for wrapper query. 2018-03-14 11:51:22 +01:00
supported-apis.asciidoc HLRest: Add get index templates API (#31161) 2018-06-11 11:06:28 -04:00