Skip to content

Commit 041a433

Browse files
authored
Add alternate examples for 2020-06-23
1 parent fddffd8 commit 041a433

File tree

170 files changed

+1267
-103
lines changed

Some content is hidden

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

170 files changed

+1267
-103
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// search.asciidoc:72
2+
3+
[source, python]
4+
----
5+
resp = client.cluster.put_settings(
6+
body={
7+
"transient": {
8+
"cluster.routing.use_adaptive_replica_selection": False
9+
}
10+
},
11+
)
12+
print(resp)
13+
----
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// docs/update-by-query.asciidoc:599
2+
3+
[source, python]
4+
----
5+
resp = client.search(
6+
index="twitter", size="0", q="extra:test", filter_path="hits.total",
7+
)
8+
print(resp)
9+
----

docs/examples/048d8abd42d094bbdcf4452a58ccb35b.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// docs/index_.asciidoc:486
1+
// docs/index_.asciidoc:487
22

33
[source, python]
44
----

docs/examples/04fe1e3a0047b0cdb10987b79fc3f3f3.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// search/request/sort.asciidoc:569
1+
// search/request/sort.asciidoc:568
22

33
[source, python]
44
----
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// cat/indices.asciidoc:94
2+
3+
[source, python]
4+
----
5+
resp = client.cat.indices(index="twi*", v=True, s="index")
6+
print(resp)
7+
----
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// indices/get-mapping.asciidoc:70
2+
3+
[source, python]
4+
----
5+
resp = client.indices.get_mapping(index="_all")
6+
print(resp)
7+
8+
resp = client.indices.get_mapping()
9+
print(resp)
10+
----
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// api-conventions.asciidoc:222
2+
3+
[source, python]
4+
----
5+
resp = client.search(
6+
q="elasticsearch",
7+
filter_path=["took", "hits.hits._id", "hits.hits._score"],
8+
)
9+
print(resp)
10+
----
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// aggregations/bucket/datehistogram-aggregation.asciidoc:214
2+
3+
[source, python]
4+
----
5+
resp = client.search(
6+
index="sales",
7+
size="0",
8+
body={
9+
"aggs": {
10+
"sales_over_time": {
11+
"date_histogram": {
12+
"field": "date",
13+
"fixed_interval": "30d",
14+
}
15+
}
16+
}
17+
},
18+
)
19+
print(resp)
20+
----

docs/examples/0cc991e3f7f8511a34730e154b3c5edc.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// docs/reindex.asciidoc:20
1+
// docs/reindex.asciidoc:24
22

33
[source, python]
44
----
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// docs/update-by-query.asciidoc:530
2+
3+
[source, python]
4+
----
5+
resp = client.update_by_query(
6+
index="twitter",
7+
body={
8+
"slice": {"id": 0, "max": 2},
9+
"script": {"source": "ctx._source['extra'] = 'test'"},
10+
},
11+
)
12+
print(resp)
13+
14+
resp = client.update_by_query(
15+
index="twitter",
16+
body={
17+
"slice": {"id": 1, "max": 2},
18+
"script": {"source": "ctx._source['extra'] = 'test'"},
19+
},
20+
)
21+
print(resp)
22+
----
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// search/request/scroll.asciidoc:206
2+
3+
[source, python]
4+
----
5+
resp = client.search(
6+
index="twitter",
7+
scroll="1m",
8+
body={
9+
"slice": {"id": 0, "max": 2},
10+
"query": {"match": {"title": "elasticsearch"}},
11+
},
12+
)
13+
print(resp)
14+
15+
resp = client.search(
16+
index="twitter",
17+
scroll="1m",
18+
body={
19+
"slice": {"id": 1, "max": 2},
20+
"query": {"match": {"title": "elasticsearch"}},
21+
},
22+
)
23+
print(resp)
24+
----

docs/examples/1216f8f7367df3aa823012cef310c08a.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// docs/reindex.asciidoc:699
1+
// docs/reindex.asciidoc:712
22

33
[source, python]
44
----
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// api-conventions.asciidoc:273
2+
3+
[source, python]
4+
----
5+
resp = client.cluster.state(filter_path="routing_table.indices.**.state")
6+
print(resp)
7+
----

docs/examples/1577e6e806b3283c9e99f1596d310754.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// docs/reindex.asciidoc:687
1+
// docs/reindex.asciidoc:700
22

33
[source, python]
44
----

docs/examples/15dad5338065baaaa7d475abe85f4c22.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// search/request/sort.asciidoc:516
1+
// search/request/sort.asciidoc:515
22

33
[source, python]
44
----
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// search.asciidoc:96
2+
3+
[source, python]
4+
----
5+
resp = client.search(
6+
body={"query": {"match_all": {}}, "stats": ["group1", "group2"]},
7+
)
8+
print(resp)
9+
----

docs/examples/18ddb7e7a4bcafd449df956e828ed7a8.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// docs/delete-by-query.asciidoc:660
1+
// docs/update-by-query.asciidoc:491
22

33
[source, python]
44
----

docs/examples/1aa91d3d48140d6367b6cabca8737b8f.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// docs/bulk.asciidoc:548
1+
// docs/bulk.asciidoc:555
22

33
[source, python]
44
----

docs/examples/1b8655e6ba99fe39933c6eafe78728b7.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// docs/reindex.asciidoc:191
1+
// docs/reindex.asciidoc:200
22

33
[source, python]
44
----

docs/examples/1b8caf0a6741126c6d0ad83b56fce290.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// indices/templates.asciidoc:148
1+
// indices/templates.asciidoc:146
22

33
[source, python]
44
----

docs/examples/1bc731a4df952228af6dfa6b48627332.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// docs/reindex.asciidoc:802
1+
// docs/reindex.asciidoc:815
22

33
[source, python]
44
----

docs/examples/1da77e114459e0b77d78a3dcc8fae429.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ resp = client.indices.create(index="twitter-2")
99
print(resp)
1010
1111
resp = client.indices.put_mapping(
12-
index="twitter-1,twitter-2",
12+
index=["twitter-1", "twitter-2"],
1313
body={"properties": {"user_name": {"type": "text"}}},
1414
)
1515
print(resp)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// api-conventions.asciidoc:250
2+
3+
[source, python]
4+
----
5+
resp = client.cluster.state(filter_path="metadata.indices.*.stat*")
6+
print(resp)
7+
----
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// api-conventions.asciidoc:317
2+
3+
[source, python]
4+
----
5+
resp = client.cluster.state(
6+
filter_path=[
7+
"metadata.indices.*.state",
8+
"-metadata.indices.logstash-*",
9+
],
10+
)
11+
print(resp)
12+
----
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// search/request/from-size.asciidoc:22
2+
3+
[source, python]
4+
----
5+
resp = client.search(
6+
body={
7+
"from": 5,
8+
"size": 20,
9+
"query": {"term": {"user.id": "8a4f500d"}},
10+
},
11+
)
12+
print(resp)
13+
----

docs/examples/1f336ecc62480c1d56351cc2f82d0d08.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// docs/index_.asciidoc:395
1+
// docs/index_.asciidoc:396
22

33
[source, python]
44
----
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// aggregations/metrics/valuecount-aggregation.asciidoc:65
2+
3+
[source, python]
4+
----
5+
resp = client.search(
6+
index="sales",
7+
size="0",
8+
body={
9+
"aggs": {
10+
"types_count": {
11+
"value_count": {
12+
"script": {
13+
"id": "my_script",
14+
"params": {"field": "type"},
15+
}
16+
}
17+
}
18+
}
19+
},
20+
)
21+
print(resp)
22+
----

docs/examples/22334f4b24bb8977d3e1bf2ffdc29d3f.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// search/request/sort.asciidoc:290
1+
// search/request/sort.asciidoc:289
22

33
[source, python]
44
----

docs/examples/23ab0f1023b1b2cd5cdf2a8f9ccfd57b.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// indices/aliases.asciidoc:292
1+
// indices/aliases.asciidoc:298
22

33
[source, python]
44
----
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// search/suggesters.asciidoc:51
2+
3+
[source, python]
4+
----
5+
resp = client.search(
6+
body={
7+
"suggest": {
8+
"my-suggest-1": {
9+
"text": "tring out Elasticsearch",
10+
"term": {"field": "message"},
11+
},
12+
"my-suggest-2": {"text": "kmichy", "term": {"field": "user"}},
13+
}
14+
},
15+
)
16+
print(resp)
17+
----

docs/examples/2891aa10ee9d474780adf94d5607f2db.asciidoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
// search/request/sort.asciidoc:154
1+
// search/request/sort.asciidoc:153
22

33
[source, python]
44
----
55
resp = client.search(
6-
index="index_long,index_double",
6+
index=["index_long", "index_double"],
77
body={"sort": [{"field": {"numeric_type": "double"}}]},
88
)
99
print(resp)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// aggregations/bucket/datehistogram-aggregation.asciidoc:232
2+
3+
[source, python]
4+
----
5+
resp = client.search(
6+
index="sales",
7+
size="0",
8+
body={
9+
"aggs": {
10+
"sales_over_time": {
11+
"date_histogram": {"field": "date", "fixed_interval": "2w"}
12+
}
13+
}
14+
},
15+
)
16+
print(resp)
17+
----
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// docs/update-by-query.asciidoc:348
2+
3+
[source, python]
4+
----
5+
resp = client.update_by_query(
6+
index="twitter",
7+
body={
8+
"script": {"source": "ctx._source.likes++", "lang": "painless"},
9+
"query": {"term": {"user": "kimchy"}},
10+
},
11+
)
12+
print(resp)
13+
----

0 commit comments

Comments
 (0)