Skip to content

Commit e427411

Browse files
committed
[DOCS] Typos, formatting, links, clarifications
1 parent c93cadb commit e427411

File tree

6 files changed

+62
-29
lines changed

6 files changed

+62
-29
lines changed

docs/configuration.asciidoc

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ $hosts = [
2626
'https://localhost', // SSL to localhost
2727
'https://192.168.1.3:9200' // SSL to IP + Port
2828
];
29-
$client = ClientBuilder::create() // Instantiate a new ClientBuilder
29+
$client = ClientBuilder::create() // Instantiate a new ClientBuilder
3030
->setHosts($hosts) // Set the hosts
3131
->build(); // Build the client object
3232
----
@@ -44,8 +44,8 @@ $hosts = [
4444
'https://localhost', // SSL to localhost
4545
'https://192.168.1.3:9200' // SSL to IP + Port
4646
];
47-
$clientBuilder = ClientBuilder::create(); // Instantiate a new ClientBuilder
48-
$clientBuilder->setHosts($hosts) // Set the hosts
47+
$clientBuilder = ClientBuilder::create(); // Instantiate a new ClientBuilder
48+
$clientBuilder->setHosts($hosts); // Set the hosts
4949
$client = $clientBuilder->build(); // Build the client object
5050
----
5151

@@ -70,14 +70,16 @@ $client = ClientBuilder::create()
7070
=== Enabling the Logger
7171
Elasticsearch-PHP supports logging, but it is not enabled by default for performance reasons. If you wish to enable logging,
7272
you need to select a logging implementation, install it, then enable the logger in the Client. The recommended logger
73-
is https://github.com/Seldaek/monolog[Monolog], but any logger that implements the PSR/Log interface will work.
73+
is https://github.com/Seldaek/monolog[Monolog], but any logger that implements the `PSR/Log` interface will work.
7474

7575
You might have noticed that Monolog was suggested during installation. To begin using Monolog, add it to your `composer.json`:
7676

7777
[source,json]
7878
----------------------------
7979
{
8080
"require": {
81+
...
82+
"elasticsearch/elasticsearch" : "~2.0",
8183
"monolog/monolog": "~1.0"
8284
}
8385
}
@@ -98,7 +100,7 @@ to do is provide the path to your desired logging location:
98100
----
99101
$logger = ClientBuilder::defaultLogger('path/to/your.log');
100102
101-
$client = ClientBuilder::create() // Instantiate a new ClientBuilder
103+
$client = ClientBuilder::create() // Instantiate a new ClientBuilder
102104
->setLogger($logger) // Set the logger with a default logger
103105
->build(); // Build the client object
104106
----
@@ -107,9 +109,10 @@ You can also specify the severity of log messages that you wish to log:
107109

108110
[source,php]
109111
----
110-
$logger = ClientBuilder::defaultLogger('/path/to/logs/', Logger::INFO); // set severity with second parameter
112+
// set severity with second parameter
113+
$logger = ClientBuilder::defaultLogger('/path/to/logs/', Logger::INFO);
111114
112-
$client = ClientBuilder::create() // Instantiate a new ClientBuilder
115+
$client = ClientBuilder::create() // Instantiate a new ClientBuilder
113116
->setLogger($logger) // Set the logger with a default logger
114117
->build(); // Build the client object
115118
----
@@ -126,7 +129,7 @@ use Monolog\Handler\StreamHandler;
126129
$logger = new Logger('name');
127130
$logger->pushHandler(new StreamHandler('path/to/your.log', Logger::WARNING));
128131
129-
$client = ClientBuilder::create() // Instantiate a new ClientBuilder
132+
$client = ClientBuilder::create() // Instantiate a new ClientBuilder
130133
->setLogger($logger) // Set your custom logger
131134
->build(); // Build the client object
132135
----
@@ -172,12 +175,13 @@ Connection pools are configured via the `setConnectionPool()` method:
172175

173176
[source,php]
174177
----
178+
$connectionPool = '\Elasticsearch\ConnectionPool\StaticNoPingConnectionPool';
175179
$client = ClientBuilder::create()
176-
->setConnectionPool('\Elasticsearch\ConnectionPool\StaticNoPingConnectionPool')
180+
->setConnectionPool($connectionPool)
177181
->build();
178182
----
179183

180-
For more details, please see the dedicated page on link:_connection-pool.html[configuring connection pools].
184+
For more details, please see the dedicated page on link:_connection_pool.html[configuring connection pools].
181185

182186
=== Setting the Connection Selector
183187

@@ -187,8 +191,9 @@ via the `setSelector()` method:
187191

188192
[source,php]
189193
----
194+
$selector = '\Elasticsearch\ConnectionPool\Selectors\StickyRoundRobinSelector';
190195
$client = ClientBuilder::create()
191-
->setSelector('\Elasticsearch\ConnectionPool\Selectors\StickyRoundRobinSelector')
196+
->setSelector($selector)
192197
->build();
193198
----
194199

@@ -206,8 +211,9 @@ it can be done via the `setSerializer()` method:
206211

207212
[source,php]
208213
----
214+
$serializer = '\Elasticsearch\Serializers\SmartSerializer';
209215
$client = ClientBuilder::create()
210-
->setSerializer('\Elasticsearch\Serializers\SmartSerializer')
216+
->setSerializer($serializer)
211217
->build();
212218
----
213219

@@ -230,10 +236,15 @@ interface.
230236
class MyConnectionFactory implements ConnectionFactoryInterface
231237
{
232238
233-
public function __construct($handler, array $connectionParams, SerializerInterface $serializer, LoggerInterface $logger, LoggerInterface $tracer)
239+
public function __construct($handler, array $connectionParams,
240+
SerializerInterface $serializer,
241+
LoggerInterface $logger,
242+
LoggerInterface $tracer)
234243
{
235244
// Code here
236245
}
246+
247+
237248
/**
238249
* @param $hostDetails
239250
*
@@ -246,10 +257,16 @@ class MyConnectionFactory implements ConnectionFactoryInterface
246257
}
247258
248259
249-
$connectionFactory = new MyConnectionFactory($handler, $connectionParams, $serializer, $logger, $tracer);
260+
$connectionFactory = new MyConnectionFactory(
261+
$handler,
262+
$connectionParams,
263+
$serializer,
264+
$logger,
265+
$tracer
266+
);
250267
251268
$client = ClientBuilder::create()
252-
->setSerializer($connectionFactory);
269+
->setConnectionFactory($connectionFactory);
253270
->build();
254271
----
255272

docs/connection-pool.asciidoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
== The Connection Pool
2+
== Connection Pool
33

44
The connection pool is an object inside the client that is responsible for maintaining the current list of nodes.
55
Theoretically, nodes are either dead or alive.
@@ -33,7 +33,7 @@ Note that the implementation is specified via a namespace path to the class.
3333
=== staticConnectionPool
3434

3535
Identical to the `staticNoPingConnectionPool`, except it pings nodes before they are used to determine if they are alive.
36-
This may be useful for long-running scripts, but tends to be additional overhead that is unescessary for average PHP scripts.
36+
This may be useful for long-running scripts, but tends to be additional overhead that is unnecessary for average PHP scripts.
3737

3838
To use the `staticConnectionPool`:
3939

docs/futures.asciidoc

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ for ($i = 0; $i < 1000; $i++) {
8989
9090
9191
foreach ($futures as $future) {
92-
echo $future['_source']; // access future's values, causing resolution if necessary
92+
// access future's values, causing resolution if necessary
93+
echo $future['_source'];
9394
}
9495
----
9596

@@ -117,7 +118,8 @@ for ($i = 0; $i < 1000; $i++) {
117118
$futures[] = $client->get($params); //queue up the request
118119
}
119120
120-
$futures[999]->wait(); //wait() forces future resolution and will execute the underlying curl batch
121+
//wait() forces future resolution and will execute the underlying curl batch
122+
$futures[999]->wait();
121123
----
122124

123125
=== Changing batch size
@@ -171,7 +173,8 @@ for ($i = 0; $i < 499; $i++) {
171173
$futures[] = $client->get($params); //queue up the request
172174
}
173175
174-
$body = $future[499]['body']; // resolve the future, and therefore the underlying batch
176+
// resolve the future, and therefore the underlying batch
177+
$body = $future[499]['body'];
175178
----
176179

177180
=== Heterogeneous batches are OK
@@ -226,23 +229,30 @@ $params = [
226229
227230
$futures['searchRequest'] = $client->search($params); // Third request
228231
229-
$searchResults = $futures['searchRequest']['hits']; // Resolve futures...blocks until network call completes
230-
$doc = $futures['getRequest']['_source']; // Should return immediately, since the previous future resolved the batch
232+
// Resolve futures...blocks until network call completes
233+
$searchResults = $futures['searchRequest']['hits'];
234+
235+
// Should return immediately, since the previous future resolved the entire batch
236+
$doc = $futures['getRequest']['_source'];
231237
----
232238

233239
=== Caveats to Future mode
234240

235241
There are a few caveats to using future mode. The biggest is also the most obvious: you need to deal with resolving the
236-
future yourself. This is usually trivia, but can sometimes introduce unexpected complications. For example, if you
237-
resolve manually using `wait()`, you may need to call `wait()` several times if there were retries. This is because
238-
each retry will introduce another layer of wrapped futures, and each needs to be resolved to get the final result.
242+
future yourself. This is usually trivia, but can sometimes introduce unexpected complications.
243+
244+
For example, if you resolve manually using `wait()`, you may need to call `wait()` several times if there were retries.
245+
This is because each retry will introduce another layer of wrapped futures, and each needs to be resolved to get the
246+
final result.
239247

240-
This is not needed if you access values via the ArrayInterface however (e.g. `$response['hits']['hits']), since
248+
This is not needed if you access values via the ArrayInterface however (e.g. `$response['hits']['hits']`), since
241249
FutureArrayInterface will automatically and fully resolve the future to provide values.
242250

243251
Another caveat is that certain APIs will lose their "helper" functionality. For example, "exists" APIs (e.g.
244252
`$client->exists()`, `$client->indices()->exists`, `$client->indices->templateExists()`, etc) typically return a true
245-
or false under normal operation. When operated in future mode, the unwrapping of the future is left to your application,
253+
or false under normal operation.
254+
255+
When operated in future mode, unwrapping of the future is left to your application,
246256
which means the client can no longer inspect the response and return a simple true/false. Instead, you'll see the raw
247257
response from Elasticsearch and will have to take action appropriately.
248258

docs/index.asciidoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ include::configuration.asciidoc[]
1111

1212
include::per-request-configuration.asciidoc[]
1313

14+
include::futures.asciidoc[]
15+
1416
include::php_json_objects.asciidoc[]
1517

1618
include::index-operations.asciidoc[]

docs/per-request-configuration.asciidoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,11 @@ $results = $future->wait(); // resolve the future
236236
----
237237

238238
Future mode supports two options: `true` or `'lazy'`. For more details about how asynchronous execution functions, and
239-
how to work with the results, see the dedicated page on link:_futures.html[Futures].
239+
how to work with the results, see the dedicated page on <<_future_mode>>.
240240

241241
=== SSL Encryption
242242

243-
Normally, you will specify SSL configurations when you link:_security[create the client], since encryption typically
243+
Normally, you will specify SSL configurations when you create the client (see <<_security>> for more details), since encryption typically
244244
applies to all requests. However, it is possible to configure on a per-request basis too if you need that functionality.
245245
For example, if you need to use a self-signed cert on a specific request, you can specify it via the `verify` parameter
246246
in the client options:

docs/selectors.asciidoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ better to "stick" to a single connection for the duration of the script.
3737
By default, this selector will randomize the hosts upon initialization, which will still guarantee an even distribution
3838
of load across the cluster. It changes the round-robin dynamics from per-request to per-script.
3939

40+
If you are using <<_future_mode>>, the "sticky" behavior of this selector will be non-ideal, since all parallel requests
41+
will go to the same node instead of multiple nodes in your cluster. When using future mode, the default `RoundRobinSelector`
42+
should be preferred.
43+
4044
If you wish to use this selector, you may do so with:
4145

4246
[source,php]

0 commit comments

Comments
 (0)