Skip to content

Commit 5169094

Browse files
authored
Merge branch 'master' into php.standard
2 parents 9bfcb1a + a997b3a commit 5169094

9 files changed

+485
-33
lines changed

.ci/Dockerfile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,4 @@ RUN composer install
3434

3535
COPY . .
3636

37-
# Updating elasticsearch submodule
38-
RUN git submodule update --init --recursive
39-
4037
CMD ["bash", ".ci/yaml-tests.sh"]

docs/breaking-changes.asciidoc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[[breaking_changes]]
2-
== Breaking changes from 6.x
2+
=== Breaking changes from 6.x
33

44
[discrete]
5-
=== E_USER_DEPRECATED notice when using deprecated parameters
5+
==== E_USER_DEPRECATED notice when using deprecated parameters
66

77
Starting from elasticsearch-php 7.4.0, we generate a PHP
88
https://www.php.net/manual/en/errorfunc.constants.php[E_USER_DEPRECATED] notice
@@ -25,21 +25,21 @@ set_error_handler(function ($errno, $errstr) {
2525
----
2626

2727
[discrete]
28-
=== Moving from types to typeless APIs in {es} 7.0
28+
==== Moving from types to typeless APIs in {es} 7.0
2929

3030
{es} 7.0 deprecated APIs that accept types, introduced new typeless APIs, and
3131
removed support for the _default_ mapping. Read
3232
https://www.elastic.co/blog/moving-from-types-to-typeless-apis-in-elasticsearch-7-0[this]
3333
blog post for more information.
3434

3535
[discrete]
36-
=== Type hint and return type
36+
==== Type hint and return type
3737

3838
Added type hints and return type declarations in all the code base where
3939
possible. See PR https://github.com/elastic/elasticsearch-php/pull/897[#897].
4040

4141
[discrete]
42-
=== PHP 7.1+ Requirement
42+
==== PHP 7.1+ Requirement
4343

4444
We require using PHP 7.1+ for elasticsearch-php. PHP 7.0 is not supported since
4545
1st Jan 2019. Refer

docs/community.asciidoc

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[[community_dsls]]
2-
== Community DSLs
2+
=== Community DSLs
33

44
[discrete]
5-
=== ElasticsearchDSL
5+
==== ElasticsearchDSL
66

77
https://github.com/ongr-io/ElasticsearchDSL[Link: ElasticsearchDSL]
88
[quote, ElasticsearchDSL]
@@ -13,7 +13,7 @@ it to an array.
1313
__________________________
1414

1515
[discrete]
16-
=== elasticsearcher
16+
==== elasticsearcher
1717

1818
https://github.com/madewithlove/elasticsearcher[Link: elasticsearcher]
1919

@@ -26,7 +26,7 @@ client.
2626
__________________________
2727

2828
[discrete]
29-
=== ElasticSearchQueryDSL
29+
==== ElasticSearchQueryDSL
3030

3131
https://github.com/gskema/elasticsearch-query-dsl-php[Link: ElasticSearchQueryDSL]
3232

@@ -38,13 +38,14 @@ explicit naming.
3838
__________________________
3939

4040

41-
== Community Integrations
41+
[[community-integrations]]
42+
=== Community Integrations
4243

4344
[discrete]
44-
=== Symfony
45+
==== Symfony
4546

4647
[discrete]
47-
==== ONGR Elasticsearch Bundle
48+
===== ONGR Elasticsearch Bundle
4849

4950
https://github.com/ongr-io/ElasticsearchBundle[Link: ONGR {es} Bundle]
5051

@@ -70,7 +71,7 @@ Technical goodies:
7071
__________________________
7172

7273
[discrete]
73-
==== FOS Elastica Bundle
74+
===== FOS Elastica Bundle
7475

7576
https://github.com/FriendsOfSymfony/FOSElasticaBundle[Link: FOS Elastica Bundle]
7677

@@ -87,10 +88,10 @@ __________________________
8788

8889

8990
[discrete]
90-
=== Drupal
91+
==== Drupal
9192

9293
[discrete]
93-
==== {es} Connector
94+
===== {es} Connector
9495

9596
https://www.drupal.org/project/elasticsearch_connector[Link: {es} Connector]
9697

@@ -101,10 +102,10 @@ Drupal.
101102
__________________________
102103

103104
[discrete]
104-
=== Laravel
105+
==== Laravel
105106

106107
[discrete]
107-
==== shift31/Laravel-Elasticsearch
108+
===== shift31/Laravel-Elasticsearch
108109

109110
https://github.com/shift31/laravel-elasticsearch[Link: shift31/Laravel-Elasticsearch]
110111

@@ -115,7 +116,7 @@ __________________________
115116

116117

117118
[discrete]
118-
==== cviebrock/Laravel-Elasticsearch
119+
===== cviebrock/Laravel-Elasticsearch
119120

120121
https://github.com/cviebrock/laravel-elasticsearch[Link: cviebrock/Laravel-Elasticsearch]
121122

@@ -126,7 +127,7 @@ __________________________
126127

127128

128129
[discrete]
129-
==== Plastic
130+
===== Plastic
130131

131132
https://github.com/sleimanx2/plastic[Link: Plastic]
132133

@@ -138,10 +139,10 @@ mapping, querying, and storing eloquent models.
138139
__________________________
139140

140141
[discrete]
141-
=== Helper
142+
==== Helper
142143

143144
[discrete]
144-
==== Index Helper
145+
===== Index Helper
145146

146147
https://github.com/Nexucis/es-php-index-helper[Link: nexucis/es-php-index-helper]
147148

docs/configuration.asciidoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ Custom configuration is accomplished before the client is instantiated, through
99
the ClientBuilder helper object. You can find all the configuration options and
1010
check sample code that helps you replace the various components.
1111

12+
To learn more about JSON in PHP, read <<php_json_objects>>.
13+
1214
* <<host-config>>
1315
* <<set-retries>>
1416
* <<enabling_logger>>
@@ -24,6 +26,8 @@ check sample code that helps you replace the various components.
2426
* <<future_mode>>
2527

2628

29+
include::php_json_objects.asciidoc[]
30+
2731
include::host-config.asciidoc[]
2832

2933
include::set-retries.asciidoc[]

docs/helpers.asciidoc

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
[[client-helpers]]
2+
== Client helpers
3+
4+
The client comes with helpers to give you a more comfortable experience with
5+
some APIs.
6+
7+
8+
[discrete]
9+
[[iterators]]
10+
=== Iterators
11+
12+
13+
[discrete]
14+
[[search-response-iterator]]
15+
==== Search response iterator
16+
17+
The `SearchResponseIterator` can be used to iterate page by page in a search
18+
result using
19+
https://www.elastic.co/guide/en/elasticsearch/reference/current/paginate-search-results.html#paginate-search-results[pagination].
20+
21+
An example as follows:
22+
23+
[source,php]
24+
----
25+
use Elasticsearch\Helper\Iterators\SearchResponseIterator;
26+
27+
$search_params = [
28+
'scroll' => '5m', // period to retain the search context
29+
'index' => '<name of index>', // here the index name
30+
'size' => 100, // 100 results per page
31+
'body' => [
32+
'query' => [
33+
'match_all' => new StdClass // {} in JSON
34+
]
35+
]
36+
];
37+
// $client is Elasticsearch\Client instance
38+
$pages = new SearchResponseIterator($client, $search_params);
39+
40+
// Sample usage of iterating over page results
41+
foreach($pages as $page) {
42+
// do something with hit e.g. copy its data to another index
43+
// e.g. prints the number of document per page (100)
44+
echo count($page['hits']['hits']), PHP_EOL;
45+
}
46+
----
47+
48+
49+
[discrete]
50+
[[search-hit-iterator]]
51+
==== Search hit iterator
52+
53+
The `SearchHitIterator` can be used to iterate in a `SearchResponseIterator`
54+
without worrying about
55+
https://www.elastic.co/guide/en/elasticsearch/reference/current/paginate-search-results.html#paginate-search-results[pagination].
56+
57+
An example as follows:
58+
59+
[source,php]
60+
----
61+
use Elasticsearch\Helper\Iterators\SearchHitIterator;
62+
use Elasticsearch\Helper\Iterators\SearchResponseIterator;
63+
64+
$search_params = [
65+
'scroll' => '5m', // period to retain the search context
66+
'index' => '<name of index>', // here the index name
67+
'size' => 100, // 100 results per page
68+
'body' => [
69+
'query' => [
70+
'match_all' => new StdClass // {} in JSON
71+
]
72+
]
73+
];
74+
// $client is Elasticsearch\Client instance
75+
$pages = new SearchResponseIterator($client, $search_params);
76+
$hits = new SearchHitIterator($pages);
77+
78+
// Sample usage of iterating over hits
79+
foreach($hits as $hit) {
80+
// do something with hit e.g. write to CSV, update a database, etc
81+
// e.g. prints the document id
82+
echo $hit['_id'], PHP_EOL;
83+
}
84+
----

docs/index.asciidoc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@ include::operations.asciidoc[]
1515

1616
include::build/classes.asciidoc[]
1717

18-
include::php_json_objects.asciidoc[]
18+
include::helpers.asciidoc[]
1919

20-
include::breaking-changes.asciidoc[]
21-
22-
include::community.asciidoc[]
20+
include::release-notes.asciidoc[]
2321

2422
include::redirects.asciidoc[]

docs/overview.asciidoc

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,22 @@ added to the client (cluster state sniffing, round-robin requests, and so on)
1414
but largely it is very barebones. This was intentional; we want a common base
1515
that more sophisticated libraries can build on top of.
1616

17+
1718
[discrete]
1819
[[psr-7-standard]]
1920
=== PSR 7 standard
2021

2122
The {es} PHP client uses the https://www.php-fig.org/psr/[PSR] 7 standard. This
2223
standard is a community effort that contains a set of interfaces defined by the
2324
PHP Framework Interop Group. For more information, refer to the
24-
https://www.php-fig.org/psr/psr-7/[PSR 7 standard documentation].
25+
https://www.php-fig.org/psr/psr-7/[PSR 7 standard documentation].
26+
27+
28+
* <<community_dsls>>
29+
* <<community-integrations>>
30+
* <<breaking_changes>>
31+
32+
33+
include::community.asciidoc[]
34+
35+
include::breaking-changes.asciidoc[]

docs/php_json_objects.asciidoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[[php_json_objects]]
2-
== Dealing with JSON arrays and objects in PHP
2+
=== Dealing with JSON arrays and objects in PHP
33

44
A common source of confusion with the client revolves around JSON arrays and
55
objects, and how to specify them in PHP. In particular, problems are caused by
66
empty objects and arrays of objects. This page shows you some common patterns
77
used in {es} JSON API and how to convert that to a PHP representation.
88

99
[discrete]
10-
=== Empty Objects
10+
==== Empty Objects
1111

1212
The {es} API uses empty JSON objects in several locations which can cause
1313
problems for PHP. Unlike other languages, PHP does not have a "short" notation
@@ -63,7 +63,7 @@ solution is the only way to acomplish the goal in PHP... there is no "short"
6363
version of an empty object.
6464

6565
[discrete]
66-
=== Arrays of Objects
66+
==== Arrays of Objects
6767

6868
Another common pattern in {es} DSL is an array of objects. For example, consider
6969
adding a sort to your query:
@@ -126,7 +126,7 @@ $results = $client->search($params);
126126
----
127127

128128
[discrete]
129-
=== Arrays of empty objects
129+
==== Arrays of empty objects
130130

131131
Occasionally, you'll encounter DSL that requires both of the previous patterns.
132132
The function score query is a good example, it sometimes requires an array of

0 commit comments

Comments
 (0)