Skip to content

Commit a035086

Browse files
committed
Merge branch 'new-code-example'
2 parents 1d6902d + 4e80275 commit a035086

File tree

128 files changed

+77426
-2586
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+77426
-2586
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ Documentation
5454
--------------
5555
[Full documentation can be found here.](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/index.html) Docs are stored within the repo under /docs/, so if you see a typo or problem, please submit a PR to fix it!
5656

57+
We also provide a code examples generator for PHP using the `util/GenerateDocExamples.php` script. This command parse the `util/alternative_report.spec.json` file produced from this [JSON specification](https://raw.githubusercontent.com/elastic/built-docs/master/raw/en/elasticsearch/reference/master/alternatives_report.json) and it generates the PHP examples foreach digest value.
58+
The examples are stored in asciidoc format under `docs/examples` folder.
59+
5760
Installation via Composer
5861
-------------------------
5962
The recommended method to install _Elasticsearch-PHP_ is through [Composer](http://getcomposer.org).
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Autogenerated from source: aggregations/bucket/terms-aggregation.asciidoc:470
2+
3+
[source, php]
4+
----
5+
$params = [
6+
'body' => [
7+
'aggs' => [
8+
'countries' => [
9+
'terms' => [
10+
'field' => 'artist.country',
11+
'order' => [
12+
[
13+
'rock>playback_stats.avg' => 'desc',
14+
],
15+
[
16+
'_count' => 'desc',
17+
],
18+
],
19+
],
20+
'aggs' => [
21+
'rock' => [
22+
'filter' => [
23+
'term' => [
24+
'genre' => 'rock',
25+
],
26+
],
27+
'aggs' => [
28+
'playback_stats' => [
29+
'stats' => [
30+
'field' => 'play_count',
31+
],
32+
],
33+
],
34+
],
35+
],
36+
],
37+
],
38+
],
39+
];
40+
$response = $client->search($params);
41+
----
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Autogenerated from source: aggregations/bucket/terms-aggregation.asciidoc:544
2+
3+
[source, php]
4+
----
5+
$params = [
6+
'body' => [
7+
'aggs' => [
8+
'genres' => [
9+
'terms' => [
10+
'script' => [
11+
'source' => 'doc[\'genre\'].value',
12+
'lang' => 'painless',
13+
],
14+
],
15+
],
16+
],
17+
],
18+
];
19+
$response = $client->search($params);
20+
----
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Autogenerated from source: docs/index_.asciidoc:486
2+
3+
[source, php]
4+
----
5+
$params = [
6+
'index' => 'twitter',
7+
'id' => '1',
8+
'body' => [
9+
'user' => 'kimchy',
10+
'post_date' => '2009-11-15T14:12:12',
11+
'message' => 'trying out Elasticsearch',
12+
],
13+
];
14+
$response = $client->create($params);
15+
----
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Autogenerated from source: query-dsl/bool-query.asciidoc:36
2+
3+
[source, php]
4+
----
5+
$params = [
6+
'body' => [
7+
'query' => [
8+
'bool' => [
9+
'must' => [
10+
'term' => [
11+
'user' => 'kimchy',
12+
],
13+
],
14+
'filter' => [
15+
'term' => [
16+
'tag' => 'tech',
17+
],
18+
],
19+
'must_not' => [
20+
'range' => [
21+
'age' => [
22+
'gte' => 10,
23+
'lte' => 20,
24+
],
25+
],
26+
],
27+
'should' => [
28+
[
29+
'term' => [
30+
'tag' => 'wow',
31+
],
32+
],
33+
[
34+
'term' => [
35+
'tag' => 'elasticsearch',
36+
],
37+
],
38+
],
39+
'minimum_should_match' => 1,
40+
'boost' => 1,
41+
],
42+
],
43+
],
44+
];
45+
$response = $client->search($params);
46+
----
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Autogenerated from source: query-dsl/match-query.asciidoc:241
2+
3+
[source, php]
4+
----
5+
$params = [
6+
'body' => [
7+
'query' => [
8+
'match' => [
9+
'message' => [
10+
'query' => 'to be or not to be',
11+
'operator' => 'and',
12+
'zero_terms_query' => 'all',
13+
],
14+
],
15+
],
16+
],
17+
];
18+
$response = $client->search($params);
19+
----
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Autogenerated from source: aggregations/bucket/terms-aggregation.asciidoc:626
2+
3+
[source, php]
4+
----
5+
$params = [
6+
'body' => [
7+
'aggs' => [
8+
'tags' => [
9+
'terms' => [
10+
'field' => 'tags',
11+
'include' => '.*sport.*',
12+
'exclude' => 'water_.*',
13+
],
14+
],
15+
],
16+
],
17+
];
18+
$response = $client->search($params);
19+
----
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Autogenerated from source: query-dsl/bool-query.asciidoc:130
2+
3+
[source, php]
4+
----
5+
$params = [
6+
'body' => [
7+
'query' => [
8+
'constant_score' => [
9+
'filter' => [
10+
'term' => [
11+
'status' => 'active',
12+
],
13+
],
14+
],
15+
],
16+
],
17+
];
18+
$response = $client->search($params);
19+
----
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Autogenerated from source: indices/create-index.asciidoc:10
2+
3+
[source, php]
4+
----
5+
$params = [
6+
'index' => 'twitter',
7+
];
8+
$response = $client->indices()->create($params);
9+
----
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Autogenerated from source: docs/index_.asciidoc:395
2+
3+
[source, php]
4+
----
5+
$params = [
6+
'index' => 'twitter',
7+
'id' => '1',
8+
'body' => [
9+
'message' => 'elasticsearch now has versioning support, double cool!',
10+
],
11+
];
12+
$response = $client->index($params);
13+
----

0 commit comments

Comments
 (0)