diff --git a/docs/examples/033838729cfb5d1a28d04f69ee78d924.asciidoc b/docs/examples/033838729cfb5d1a28d04f69ee78d924.asciidoc new file mode 100644 index 000000000..ead161354 --- /dev/null +++ b/docs/examples/033838729cfb5d1a28d04f69ee78d924.asciidoc @@ -0,0 +1,25 @@ +// mapping/types/geo-shape.asciidoc:300 + +[source, python] +---- +resp = client.index( + index="example", + body={ + "location": { + "type": "Polygon", + "orientation": "LEFT", + "coordinates": [ + [ + [-177, 10], + [176, 15], + [172, 0], + [176, -15], + [-177, -10], + [-177, 10], + ] + ], + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/05500e77aef581d92f6c605f7a48f7df.asciidoc b/docs/examples/05500e77aef581d92f6c605f7a48f7df.asciidoc new file mode 100644 index 000000000..d3bb50fc5 --- /dev/null +++ b/docs/examples/05500e77aef581d92f6c605f7a48f7df.asciidoc @@ -0,0 +1,23 @@ +// mapping/types/shape.asciidoc:199 + +[source, python] +---- +resp = client.index( + index="example", + body={ + "location": { + "type": "polygon", + "coordinates": [ + [ + [1000, -1001], + [1001, -1001], + [1001, -1000], + [1000, -1000], + [1000, -1001], + ] + ], + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/07de76cb0e7f11c7533788faf8c093c3.asciidoc b/docs/examples/07de76cb0e7f11c7533788faf8c093c3.asciidoc new file mode 100644 index 000000000..7c4ac788f --- /dev/null +++ b/docs/examples/07de76cb0e7f11c7533788faf8c093c3.asciidoc @@ -0,0 +1,17 @@ +// mapping/types/flattened.asciidoc:205 + +[source, python] +---- +resp = client.indices.create( + index="my-index-000001", + body={ + "mappings": { + "properties": { + "title": {"type": "text"}, + "labels": {"type": "flattened"}, + } + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/0b987b4101e016653a32d7b092d47e4c.asciidoc b/docs/examples/0b987b4101e016653a32d7b092d47e4c.asciidoc new file mode 100644 index 000000000..a24c368ff --- /dev/null +++ b/docs/examples/0b987b4101e016653a32d7b092d47e4c.asciidoc @@ -0,0 +1,27 @@ +// mapping/types/object.asciidoc:46 + +[source, python] +---- +resp = client.indices.create( + index="my-index-000001", + body={ + "mappings": { + "properties": { + "region": {"type": "keyword"}, + "manager": { + "properties": { + "age": {"type": "integer"}, + "name": { + "properties": { + "first": {"type": "text"}, + "last": {"type": "text"}, + } + }, + } + }, + } + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/0c2ca704a39dda8b3a7c5806ec6c6cf8.asciidoc b/docs/examples/0c2ca704a39dda8b3a7c5806ec6c6cf8.asciidoc new file mode 100644 index 000000000..cb5d4a15b --- /dev/null +++ b/docs/examples/0c2ca704a39dda8b3a7c5806ec6c6cf8.asciidoc @@ -0,0 +1,17 @@ +// mapping/runtime.asciidoc:1379 + +[source, python] +---- +resp = client.indices.put_mapping( + index="my-index-000001", + body={ + "runtime": { + "http.client_ip": { + "type": "ip", + "script": "\n String clientip=grok('%{COMMONAPACHELOG}').extract(doc[\"message\"].value)?.clientip;\n if (clientip != null) emit(clientip); \n ", + } + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/0db06c3cba57cf442ac7fab89966e1e1.asciidoc b/docs/examples/0db06c3cba57cf442ac7fab89966e1e1.asciidoc new file mode 100644 index 000000000..b08ce0267 --- /dev/null +++ b/docs/examples/0db06c3cba57cf442ac7fab89966e1e1.asciidoc @@ -0,0 +1,28 @@ +// mapping/types/parent-join.asciidoc:76 + +[source, python] +---- +resp = client.index( + index="my-index-000001", + id="1", + refresh=True, + body={ + "my_id": "1", + "text": "This is a question", + "my_join_field": "question", + }, +) +print(resp) + +resp = client.index( + index="my-index-000001", + id="2", + refresh=True, + body={ + "my_id": "2", + "text": "This is another question", + "my_join_field": "question", + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/0fb472645116d58ddef89ca976d15a01.asciidoc b/docs/examples/0fb472645116d58ddef89ca976d15a01.asciidoc new file mode 100644 index 000000000..a48488b5b --- /dev/null +++ b/docs/examples/0fb472645116d58ddef89ca976d15a01.asciidoc @@ -0,0 +1,48 @@ +// mapping/runtime.asciidoc:471 + +[source, python] +---- +resp = client.bulk( + index="my-index-000001", + refresh="true", + body=[ + {"index": {}}, + { + "@timestamp": 1516729294000, + "model_number": "QVKC92Q", + "measures": {"voltage": 5.2}, + }, + {"index": {}}, + { + "@timestamp": 1516642894000, + "model_number": "QVKC92Q", + "measures": {"voltage": 5.8}, + }, + {"index": {}}, + { + "@timestamp": 1516556494000, + "model_number": "QVKC92Q", + "measures": {"voltage": 5.1}, + }, + {"index": {}}, + { + "@timestamp": 1516470094000, + "model_number": "QVKC92Q", + "measures": {"voltage": 5.6}, + }, + {"index": {}}, + { + "@timestamp": 1516383694000, + "model_number": "HG537PU", + "measures": {"voltage": 4.2}, + }, + {"index": {}}, + { + "@timestamp": 1516297294000, + "model_number": "HG537PU", + "measures": {"voltage": 4}, + }, + ], +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/100d4e33158069f3caa32e8bfa0eb3d0.asciidoc b/docs/examples/100d4e33158069f3caa32e8bfa0eb3d0.asciidoc new file mode 100644 index 000000000..0054253c7 --- /dev/null +++ b/docs/examples/100d4e33158069f3caa32e8bfa0eb3d0.asciidoc @@ -0,0 +1,15 @@ +// mapping/runtime.asciidoc:175 + +[source, python] +---- +resp = client.indices.create( + index="my-index-000001", + body={ + "mappings": { + "dynamic": "runtime", + "properties": {"@timestamp": {"type": "date"}}, + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/10535507a9735fcf06600444b9067d4c.asciidoc b/docs/examples/10535507a9735fcf06600444b9067d4c.asciidoc new file mode 100644 index 000000000..2e19678f8 --- /dev/null +++ b/docs/examples/10535507a9735fcf06600444b9067d4c.asciidoc @@ -0,0 +1,33 @@ +// mapping/types/text.asciidoc:181 + +[source, python] +---- +resp = client.indices.create( + index="idx", + body={ + "mappings": { + "_source": {"mode": "synthetic"}, + "properties": { + "text": { + "type": "text", + "fields": {"raw": {"type": "keyword"}}, + } + }, + } + }, +) +print(resp) + +resp = client.index( + index="idx", + id="1", + body={ + "text": [ + "the quick brown fox", + "the quick brown fox", + "jumped over the lazy dog", + ] + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/1233be1d4c9c7ca54126f1a0693b26de.asciidoc b/docs/examples/1233be1d4c9c7ca54126f1a0693b26de.asciidoc new file mode 100644 index 000000000..0aac0cbc7 --- /dev/null +++ b/docs/examples/1233be1d4c9c7ca54126f1a0693b26de.asciidoc @@ -0,0 +1,30 @@ +// mapping/types/parent-join.asciidoc:104 + +[source, python] +---- +resp = client.index( + index="my-index-000001", + id="3", + routing="1", + refresh=True, + body={ + "my_id": "3", + "text": "This is an answer", + "my_join_field": {"name": "answer", "parent": "1"}, + }, +) +print(resp) + +resp = client.index( + index="my-index-000001", + id="4", + routing="1", + refresh=True, + body={ + "my_id": "4", + "text": "This is another answer", + "my_join_field": {"name": "answer", "parent": "1"}, + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/14a49c13c399840e64c00b487aa820c9.asciidoc b/docs/examples/14a49c13c399840e64c00b487aa820c9.asciidoc new file mode 100644 index 000000000..0cbdc76c0 --- /dev/null +++ b/docs/examples/14a49c13c399840e64c00b487aa820c9.asciidoc @@ -0,0 +1,24 @@ +// mapping/types/date_nanos.asciidoc:160 + +[source, python] +---- +resp = client.indices.create( + index="idx", + body={ + "mappings": { + "_source": {"mode": "synthetic"}, + "properties": {"date": {"type": "date_nanos"}}, + } + }, +) +print(resp) + +resp = client.index( + index="idx", + id="1", + body={ + "date": ["2015-01-01T12:10:30.000Z", "2014-01-01T12:10:30.000Z"] + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/14afe65afee3d43f27aaaa5b37f26a31.asciidoc b/docs/examples/14afe65afee3d43f27aaaa5b37f26a31.asciidoc new file mode 100644 index 000000000..b766a5b55 --- /dev/null +++ b/docs/examples/14afe65afee3d43f27aaaa5b37f26a31.asciidoc @@ -0,0 +1,15 @@ +// mapping/types/geo-shape.asciidoc:165 + +[source, python] +---- +resp = client.index( + index="example", + body={ + "location": { + "type": "Point", + "coordinates": [-77.03653, 38.897676], + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/14f124294a4a0e3a657d1468c36161cd.asciidoc b/docs/examples/14f124294a4a0e3a657d1468c36161cd.asciidoc new file mode 100644 index 000000000..58e6b33e9 --- /dev/null +++ b/docs/examples/14f124294a4a0e3a657d1468c36161cd.asciidoc @@ -0,0 +1,10 @@ +// mapping/types/aggregate-metric-double.asciidoc:205 + +[source, python] +---- +resp = client.search( + index="stats-index", + body={"query": {"term": {"agg_metric": {"value": 702.3}}}}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/154d703732daf5c5fcd0122e6a50213f.asciidoc b/docs/examples/154d703732daf5c5fcd0122e6a50213f.asciidoc new file mode 100644 index 000000000..256264c02 --- /dev/null +++ b/docs/examples/154d703732daf5c5fcd0122e6a50213f.asciidoc @@ -0,0 +1,15 @@ +// mapping/runtime.asciidoc:339 + +[source, python] +---- +resp = client.indices.put_mapping( + index="my-index-000001", + body={ + "runtime": { + "measures.start": {"type": "long"}, + "measures.end": {"type": "long"}, + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/1572696b97822d3332be51700e09672f.asciidoc b/docs/examples/1572696b97822d3332be51700e09672f.asciidoc new file mode 100644 index 000000000..cc4b2fe28 --- /dev/null +++ b/docs/examples/1572696b97822d3332be51700e09672f.asciidoc @@ -0,0 +1,20 @@ +// mapping/types/range.asciidoc:130 + +[source, python] +---- +resp = client.search( + index="range_index", + body={ + "query": { + "range": { + "time_frame": { + "gte": "2015-10-31", + "lte": "2015-11-01", + "relation": "within", + } + } + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/169b39bb889ecd47541bed3e48725488.asciidoc b/docs/examples/169b39bb889ecd47541bed3e48725488.asciidoc new file mode 100644 index 000000000..148c52898 --- /dev/null +++ b/docs/examples/169b39bb889ecd47541bed3e48725488.asciidoc @@ -0,0 +1,10 @@ +// mapping/types/flattened.asciidoc:73 + +[source, python] +---- +resp = client.search( + index="bug_reports", + body={"query": {"term": {"labels": "urgent"}}}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/17f8a8990b0166befa3bc2b10fd28134.asciidoc b/docs/examples/17f8a8990b0166befa3bc2b10fd28134.asciidoc new file mode 100644 index 000000000..19f6bb503 --- /dev/null +++ b/docs/examples/17f8a8990b0166befa3bc2b10fd28134.asciidoc @@ -0,0 +1,11 @@ +// mapping/types/percolator.asciidoc:40 + +[source, python] +---- +resp = client.index( + index="my-index-000001", + id="match_value", + body={"query": {"match": {"field": "value"}}}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/1adee74383e5594e45c937177d75aa2a.asciidoc b/docs/examples/1adee74383e5594e45c937177d75aa2a.asciidoc new file mode 100644 index 000000000..0a34971f4 --- /dev/null +++ b/docs/examples/1adee74383e5594e45c937177d75aa2a.asciidoc @@ -0,0 +1,10 @@ +// mapping/types/unsigned_long.asciidoc:93 + +[source, python] +---- +resp = client.search( + index="my_index", + body={"query": {"match_all": {}}, "sort": {"my_counter": "desc"}}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/1cadbcf2cfeb312f73b7f098291356ac.asciidoc b/docs/examples/1cadbcf2cfeb312f73b7f098291356ac.asciidoc new file mode 100644 index 000000000..e88f56b47 --- /dev/null +++ b/docs/examples/1cadbcf2cfeb312f73b7f098291356ac.asciidoc @@ -0,0 +1,10 @@ +// mapping/types/geo-shape.asciidoc:346 + +[source, python] +---- +resp = client.index( + index="example", + body={"location": "MULTIPOINT (102.0 2.0, 103.0 2.0)"}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/1cfa04e9654c1484e3d4c75bf439400a.asciidoc b/docs/examples/1cfa04e9654c1484e3d4c75bf439400a.asciidoc new file mode 100644 index 000000000..7966355af --- /dev/null +++ b/docs/examples/1cfa04e9654c1484e3d4c75bf439400a.asciidoc @@ -0,0 +1,30 @@ +// mapping/types/shape.asciidoc:226 + +[source, python] +---- +resp = client.index( + index="example", + body={ + "location": { + "type": "polygon", + "coordinates": [ + [ + [1000, -1001], + [1001, -1001], + [1001, -1000], + [1000, -1000], + [1000, -1001], + ], + [ + [1000.2, -1001.2], + [1000.8, -1001.2], + [1000.8, -1001.8], + [1000.2, -1001.8], + [1000.2, -1001.2], + ], + ], + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/1d827ae674970692643ea81991e5396e.asciidoc b/docs/examples/1d827ae674970692643ea81991e5396e.asciidoc new file mode 100644 index 000000000..dbc6a01a6 --- /dev/null +++ b/docs/examples/1d827ae674970692643ea81991e5396e.asciidoc @@ -0,0 +1,36 @@ +// mapping/types/flattened.asciidoc:334 + +[source, python] +---- +resp = client.indices.create( + index="idx", + body={ + "mappings": { + "_source": {"mode": "synthetic"}, + "properties": {"flattened": {"type": "flattened"}}, + } + }, +) +print(resp) + +resp = client.index( + index="idx", + id="1", + body={ + "flattened": { + "field": [ + "apple", + "apple", + "banana", + "avocado", + "10", + "200", + "AVOCADO", + "Banana", + "Tangerine", + ] + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/1e0f203aced9344382081ab095c44dde.asciidoc b/docs/examples/1e0f203aced9344382081ab095c44dde.asciidoc new file mode 100644 index 000000000..324ddb67f --- /dev/null +++ b/docs/examples/1e0f203aced9344382081ab095c44dde.asciidoc @@ -0,0 +1,28 @@ +// mapping/types/text.asciidoc:230 + +[source, python] +---- +resp = client.indices.create( + index="idx", + body={ + "mappings": { + "_source": {"mode": "synthetic"}, + "properties": {"text": {"type": "text", "store": True}}, + } + }, +) +print(resp) + +resp = client.index( + index="idx", + id="1", + body={ + "text": [ + "the quick brown fox", + "the quick brown fox", + "jumped over the lazy dog", + ] + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/2081739da0c69de8af6f5bf9e94433e6.asciidoc b/docs/examples/2081739da0c69de8af6f5bf9e94433e6.asciidoc new file mode 100644 index 000000000..10908c87a --- /dev/null +++ b/docs/examples/2081739da0c69de8af6f5bf9e94433e6.asciidoc @@ -0,0 +1,12 @@ +// mapping/types/geo-shape.asciidoc:377 + +[source, python] +---- +resp = client.index( + index="example", + body={ + "location": "MULTILINESTRING ((102.0 2.0, 103.0 2.0, 103.0 3.0, 102.0 3.0), (100.0 0.0, 101.0 0.0, 101.0 1.0, 100.0 1.0), (100.2 0.2, 100.8 0.2, 100.8 0.8, 100.2 0.8))" + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/20bc71cc5bbe04184e27827f3777a406.asciidoc b/docs/examples/20bc71cc5bbe04184e27827f3777a406.asciidoc new file mode 100644 index 000000000..8a4ab2012 --- /dev/null +++ b/docs/examples/20bc71cc5bbe04184e27827f3777a406.asciidoc @@ -0,0 +1,10 @@ +// mapping/runtime.asciidoc:723 + +[source, python] +---- +resp = client.search( + index="my-index-000001", + body={"fields": ["@timestamp", "day_of_week"], "_source": False}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/229b83cbcd8efa1b0288a728a2abacb4.asciidoc b/docs/examples/229b83cbcd8efa1b0288a728a2abacb4.asciidoc new file mode 100644 index 000000000..6f01448f2 --- /dev/null +++ b/docs/examples/229b83cbcd8efa1b0288a728a2abacb4.asciidoc @@ -0,0 +1,54 @@ +// mapping/types/point.asciidoc:21 + +[source, python] +---- +resp = client.indices.create( + index="my-index-000001", + body={"mappings": {"properties": {"location": {"type": "point"}}}}, +) +print(resp) + +resp = client.index( + index="my-index-000001", + id="1", + body={ + "text": "Point as an object using GeoJSON format", + "location": {"type": "Point", "coordinates": [-71.34, 41.12]}, + }, +) +print(resp) + +resp = client.index( + index="my-index-000001", + id="2", + body={ + "text": "Point as a WKT POINT primitive", + "location": "POINT (-71.34 41.12)", + }, +) +print(resp) + +resp = client.index( + index="my-index-000001", + id="3", + body={ + "text": "Point as an object with 'x' and 'y' keys", + "location": {"x": -71.34, "y": 41.12}, + }, +) +print(resp) + +resp = client.index( + index="my-index-000001", + id="4", + body={"text": "Point as an array", "location": [-71.34, 41.12]}, +) +print(resp) + +resp = client.index( + index="my-index-000001", + id="5", + body={"text": "Point as a string", "location": "-71.34,41.12"}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/22cb99d4e6ba3101a2d9f59764a90877.asciidoc b/docs/examples/22cb99d4e6ba3101a2d9f59764a90877.asciidoc new file mode 100644 index 000000000..d255c66f4 --- /dev/null +++ b/docs/examples/22cb99d4e6ba3101a2d9f59764a90877.asciidoc @@ -0,0 +1,10 @@ +// mapping/types/geo-shape.asciidoc:178 + +[source, python] +---- +resp = client.index( + index="example", + body={"location": "POINT (-77.03653 38.897676)"}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/22d8e92b4100f8e4f52260ef8d3aa2b2.asciidoc b/docs/examples/22d8e92b4100f8e4f52260ef8d3aa2b2.asciidoc new file mode 100644 index 000000000..ca64d8b50 --- /dev/null +++ b/docs/examples/22d8e92b4100f8e4f52260ef8d3aa2b2.asciidoc @@ -0,0 +1,24 @@ +// mapping/types/binary.asciidoc:12 + +[source, python] +---- +resp = client.indices.create( + index="my-index-000001", + body={ + "mappings": { + "properties": { + "name": {"type": "text"}, + "blob": {"type": "binary"}, + } + } + }, +) +print(resp) + +resp = client.index( + index="my-index-000001", + id="1", + body={"name": "Some binary blob", "blob": "U29tZSBiaW5hcnkgYmxvYg=="}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/2646710ece0c4c843aebeacd370d0396.asciidoc b/docs/examples/2646710ece0c4c843aebeacd370d0396.asciidoc new file mode 100644 index 000000000..9c8587712 --- /dev/null +++ b/docs/examples/2646710ece0c4c843aebeacd370d0396.asciidoc @@ -0,0 +1,21 @@ +// mapping/types/dense-vector.asciidoc:126 + +[source, python] +---- +resp = client.indices.create( + index="my-byte-quantized-index", + body={ + "mappings": { + "properties": { + "my_vector": { + "type": "dense_vector", + "dims": 3, + "index": True, + "index_options": {"type": "int8_hnsw"}, + } + } + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/2716453454dbf9c6dde2ea6850a62214.asciidoc b/docs/examples/2716453454dbf9c6dde2ea6850a62214.asciidoc new file mode 100644 index 000000000..584040f0c --- /dev/null +++ b/docs/examples/2716453454dbf9c6dde2ea6850a62214.asciidoc @@ -0,0 +1,26 @@ +// mapping/types/alias.asciidoc:12 + +[source, python] +---- +resp = client.indices.create( + index="trips", + body={ + "mappings": { + "properties": { + "distance": {"type": "long"}, + "route_length_miles": { + "type": "alias", + "path": "distance", + }, + "transit_mode": {"type": "keyword"}, + } + } + }, +) +print(resp) + +resp = client.search( + body={"query": {"range": {"route_length_miles": {"gte": 39}}}}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/2740b69e7246ac6d1ad249382f21d534.asciidoc b/docs/examples/2740b69e7246ac6d1ad249382f21d534.asciidoc new file mode 100644 index 000000000..123b036f7 --- /dev/null +++ b/docs/examples/2740b69e7246ac6d1ad249382f21d534.asciidoc @@ -0,0 +1,20 @@ +// mapping/types/aggregate-metric-double.asciidoc:26 + +[source, python] +---- +resp = client.indices.create( + index="my-index", + body={ + "mappings": { + "properties": { + "my-agg-metric-field": { + "type": "aggregate_metric_double", + "metrics": ["min", "max", "sum", "value_count"], + "default_metric": "max", + } + } + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/274feaaa727e0ddf61b3c0f093182839.asciidoc b/docs/examples/274feaaa727e0ddf61b3c0f093182839.asciidoc new file mode 100644 index 000000000..bdf15c2c8 --- /dev/null +++ b/docs/examples/274feaaa727e0ddf61b3c0f093182839.asciidoc @@ -0,0 +1,20 @@ +// mapping/runtime.asciidoc:414 + +[source, python] +---- +resp = client.search( + index="my-index-000001", + body={ + "runtime_mappings": { + "duration": { + "type": "long", + "script": { + "source": "\n emit(doc['measures.end'].value - doc['measures.start'].value);\n " + }, + } + }, + "aggs": {"duration_stats": {"stats": {"field": "duration"}}}, + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/27600d6a78623b69689d4218618e4278.asciidoc b/docs/examples/27600d6a78623b69689d4218618e4278.asciidoc new file mode 100644 index 000000000..c1b03d097 --- /dev/null +++ b/docs/examples/27600d6a78623b69689d4218618e4278.asciidoc @@ -0,0 +1,10 @@ +// mapping/types/unsigned_long.asciidoc:47 + +[source, python] +---- +resp = client.search( + index="my_index", + body={"query": {"term": {"my_counter": 18446744073709552000}}}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/2826510e4aeb1c0d8dc43d317ed7624a.asciidoc b/docs/examples/2826510e4aeb1c0d8dc43d317ed7624a.asciidoc new file mode 100644 index 000000000..35301e8eb --- /dev/null +++ b/docs/examples/2826510e4aeb1c0d8dc43d317ed7624a.asciidoc @@ -0,0 +1,22 @@ +// mapping/types/boolean.asciidoc:242 + +[source, python] +---- +resp = client.indices.create( + index="idx", + body={ + "mappings": { + "_source": {"mode": "synthetic"}, + "properties": {"bool": {"type": "boolean"}}, + } + }, +) +print(resp) + +resp = client.index( + index="idx", + id="1", + body={"bool": [True, False, True, False]}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/2b5a5f8689f04d095fa86570130ee4d4.asciidoc b/docs/examples/2b5a5f8689f04d095fa86570130ee4d4.asciidoc new file mode 100644 index 000000000..df11931b5 --- /dev/null +++ b/docs/examples/2b5a5f8689f04d095fa86570130ee4d4.asciidoc @@ -0,0 +1,20 @@ +// mapping/types/parent-join.asciidoc:22 + +[source, python] +---- +resp = client.indices.create( + index="my-index-000001", + body={ + "mappings": { + "properties": { + "my_id": {"type": "keyword"}, + "my_join_field": { + "type": "join", + "relations": {"question": "answer"}, + }, + } + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/2c090fe7ec7b66b3f5c178d71c46323b.asciidoc b/docs/examples/2c090fe7ec7b66b3f5c178d71c46323b.asciidoc new file mode 100644 index 000000000..0be08a366 --- /dev/null +++ b/docs/examples/2c090fe7ec7b66b3f5c178d71c46323b.asciidoc @@ -0,0 +1,19 @@ +// mapping/types/parent-join.asciidoc:403 + +[source, python] +---- +resp = client.indices.stats( + metric="fielddata", + human=True, + fields="my_join_field", +) +print(resp) + +resp = client.nodes.stats( + metric="indices", + index_metric="fielddata", + human=True, + fields="my_join_field", +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/2c44657adf550b8ade5cf5334106d38b.asciidoc b/docs/examples/2c44657adf550b8ade5cf5334106d38b.asciidoc new file mode 100644 index 000000000..1f96b6cea --- /dev/null +++ b/docs/examples/2c44657adf550b8ade5cf5334106d38b.asciidoc @@ -0,0 +1,19 @@ +// mapping/runtime.asciidoc:1406 + +[source, python] +---- +resp = client.search( + index="my-index-000001", + body={ + "runtime_mappings": { + "http.clientip": { + "type": "ip", + "script": "\n String clientip=grok('%{COMMONAPACHELOG}').extract(doc[\"message\"].value)?.clientip;\n if (clientip != null) emit(clientip);\n ", + } + }, + "query": {"match": {"http.clientip": "40.135.0.0"}}, + "fields": ["http.clientip"], + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/2d37b02cbf6d30ae11bf239a54ec9423.asciidoc b/docs/examples/2d37b02cbf6d30ae11bf239a54ec9423.asciidoc new file mode 100644 index 000000000..fa3f3f3ec --- /dev/null +++ b/docs/examples/2d37b02cbf6d30ae11bf239a54ec9423.asciidoc @@ -0,0 +1,72 @@ +// mapping/runtime.asciidoc:316 + +[source, python] +---- +resp = client.bulk( + index="my-index-000001", + refresh="true", + body=[ + {"index": {}}, + { + "@timestamp": 1516729294000, + "model_number": "QVKC92Q", + "measures": { + "voltage": "5.2", + "start": "300", + "end": "8675309", + }, + }, + {"index": {}}, + { + "@timestamp": 1516642894000, + "model_number": "QVKC92Q", + "measures": { + "voltage": "5.8", + "start": "300", + "end": "8675309", + }, + }, + {"index": {}}, + { + "@timestamp": 1516556494000, + "model_number": "QVKC92Q", + "measures": { + "voltage": "5.1", + "start": "300", + "end": "8675309", + }, + }, + {"index": {}}, + { + "@timestamp": 1516470094000, + "model_number": "QVKC92Q", + "measures": { + "voltage": "5.6", + "start": "300", + "end": "8675309", + }, + }, + {"index": {}}, + { + "@timestamp": 1516383694000, + "model_number": "HG537PU", + "measures": { + "voltage": "4.2", + "start": "400", + "end": "8625309", + }, + }, + {"index": {}}, + { + "@timestamp": 1516297294000, + "model_number": "HG537PU", + "measures": { + "voltage": "4.0", + "start": "400", + "end": "8625309", + }, + }, + ], +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/2e847378ba26aa64d40186b6e3e6a1da.asciidoc b/docs/examples/2e847378ba26aa64d40186b6e3e6a1da.asciidoc new file mode 100644 index 000000000..9449ddf4d --- /dev/null +++ b/docs/examples/2e847378ba26aa64d40186b6e3e6a1da.asciidoc @@ -0,0 +1,19 @@ +// mapping/types/unsigned_long.asciidoc:159 + +[source, python] +---- +resp = client.search( + index="my_index", + body={ + "query": { + "script_score": { + "query": {"match_all": {}}, + "script": { + "source": "field('my_counter').asBigInteger(BigInteger.ZERO).floatValue()" + }, + } + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/2ebcdd00ccbf26b4c8e6d9c80dfb3d55.asciidoc b/docs/examples/2ebcdd00ccbf26b4c8e6d9c80dfb3d55.asciidoc new file mode 100644 index 000000000..ff105c179 --- /dev/null +++ b/docs/examples/2ebcdd00ccbf26b4c8e6d9c80dfb3d55.asciidoc @@ -0,0 +1,18 @@ +// mapping/types/shape.asciidoc:170 + +[source, python] +---- +resp = client.index( + index="example", + body={ + "location": { + "type": "linestring", + "coordinates": [ + [-377.03653, 389.897676], + [-377.009051, 389.889939], + ], + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/2f2fd35905feef0b561c05d70c7064c1.asciidoc b/docs/examples/2f2fd35905feef0b561c05d70c7064c1.asciidoc new file mode 100644 index 000000000..2ade0d3bb --- /dev/null +++ b/docs/examples/2f2fd35905feef0b561c05d70c7064c1.asciidoc @@ -0,0 +1,9 @@ +// mapping/dynamic/templates.asciidoc:570 + +[source, python] +---- +resp = client.indices.get_mapping( + index="my-index-000001", +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/2f4a55dfeba8851b306ef9c1b216ef54.asciidoc b/docs/examples/2f4a55dfeba8851b306ef9c1b216ef54.asciidoc new file mode 100644 index 000000000..c8f7d32ac --- /dev/null +++ b/docs/examples/2f4a55dfeba8851b306ef9c1b216ef54.asciidoc @@ -0,0 +1,10 @@ +// mapping/types/flattened.asciidoc:85 + +[source, python] +---- +resp = client.search( + index="bug_reports", + body={"query": {"term": {"labels.release": "v1.3.0"}}}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/318e209cc4d6f306e65cb2f5598a50b1.asciidoc b/docs/examples/318e209cc4d6f306e65cb2f5598a50b1.asciidoc new file mode 100644 index 000000000..a57d005c7 --- /dev/null +++ b/docs/examples/318e209cc4d6f306e65cb2f5598a50b1.asciidoc @@ -0,0 +1,18 @@ +// mapping/types/geo-shape.asciidoc:195 + +[source, python] +---- +resp = client.index( + index="example", + body={ + "location": { + "type": "LineString", + "coordinates": [ + [-77.03653, 38.897676], + [-77.009051, 38.889939], + ], + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/31ac1b68dc7c26a1d37350be47ae9381.asciidoc b/docs/examples/31ac1b68dc7c26a1d37350be47ae9381.asciidoc new file mode 100644 index 000000000..39a50a96a --- /dev/null +++ b/docs/examples/31ac1b68dc7c26a1d37350be47ae9381.asciidoc @@ -0,0 +1,10 @@ +// mapping/types/completion.asciidoc:12 + +[source, python] +---- +resp = client.indices.create( + index="music", + body={"mappings": {"properties": {"suggest": {"type": "completion"}}}}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/32a7acdfb7046966b28f394476c99126.asciidoc b/docs/examples/32a7acdfb7046966b28f394476c99126.asciidoc new file mode 100644 index 000000000..6b09d64d9 --- /dev/null +++ b/docs/examples/32a7acdfb7046966b28f394476c99126.asciidoc @@ -0,0 +1,10 @@ +// mapping/types/shape.asciidoc:153 + +[source, python] +---- +resp = client.index( + index="example", + body={"location": "POINT (-377.03653 389.897676)"}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/331caebf810a923644eb6de26e5a97f4.asciidoc b/docs/examples/331caebf810a923644eb6de26e5a97f4.asciidoc new file mode 100644 index 000000000..0991fb2bb --- /dev/null +++ b/docs/examples/331caebf810a923644eb6de26e5a97f4.asciidoc @@ -0,0 +1,19 @@ +// mapping/types/parent-join.asciidoc:417 + +[source, python] +---- +resp = client.indices.create( + index="my-index-000001", + body={ + "mappings": { + "properties": { + "my_join_field": { + "type": "join", + "relations": {"question": ["answer", "comment"]}, + } + } + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/33732208fc6e6fe1e8d278299681932e.asciidoc b/docs/examples/33732208fc6e6fe1e8d278299681932e.asciidoc new file mode 100644 index 000000000..34850898d --- /dev/null +++ b/docs/examples/33732208fc6e6fe1e8d278299681932e.asciidoc @@ -0,0 +1,12 @@ +// mapping/types/shape.asciidoc:183 + +[source, python] +---- +resp = client.index( + index="example", + body={ + "location": "LINESTRING (-377.03653 389.897676, -377.009051 389.889939)" + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/343dd09a8c76987e586858be3bdc51eb.asciidoc b/docs/examples/343dd09a8c76987e586858be3bdc51eb.asciidoc new file mode 100644 index 000000000..42711cb15 --- /dev/null +++ b/docs/examples/343dd09a8c76987e586858be3bdc51eb.asciidoc @@ -0,0 +1,53 @@ +// mapping/types/percolator.asciidoc:574 + +[source, python] +---- +resp = client.indices.create( + index="my_queries2", + body={ + "settings": { + "analysis": { + "analyzer": { + "wildcard_suffix": { + "type": "custom", + "tokenizer": "standard", + "filter": [ + "lowercase", + "reverse", + "wildcard_edge_ngram", + ], + }, + "wildcard_suffix_search_time": { + "type": "custom", + "tokenizer": "standard", + "filter": ["lowercase", "reverse"], + }, + }, + "filter": { + "wildcard_edge_ngram": { + "type": "edge_ngram", + "min_gram": 1, + "max_gram": 32, + } + }, + } + }, + "mappings": { + "properties": { + "query": {"type": "percolator"}, + "my_field": { + "type": "text", + "fields": { + "suffix": { + "type": "text", + "analyzer": "wildcard_suffix", + "search_analyzer": "wildcard_suffix_search_time", + } + }, + }, + } + }, + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/35c33ef48cf8a4ee368874141622f9d5.asciidoc b/docs/examples/35c33ef48cf8a4ee368874141622f9d5.asciidoc new file mode 100644 index 000000000..d0a154874 --- /dev/null +++ b/docs/examples/35c33ef48cf8a4ee368874141622f9d5.asciidoc @@ -0,0 +1,21 @@ +// mapping/dynamic/templates.asciidoc:503 + +[source, python] +---- +resp = client.indices.create( + index="my-index-000001", + body={ + "mappings": { + "dynamic_templates": [ + { + "strings_as_text": { + "match_mapping_type": "string", + "mapping": {"type": "text"}, + } + } + ] + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/35f892b475a1770f18328158be7039fd.asciidoc b/docs/examples/35f892b475a1770f18328158be7039fd.asciidoc new file mode 100644 index 000000000..c47e692e7 --- /dev/null +++ b/docs/examples/35f892b475a1770f18328158be7039fd.asciidoc @@ -0,0 +1,20 @@ +// mapping/types/dense-vector.asciidoc:72 + +[source, python] +---- +resp = client.indices.create( + index="my-index-2", + body={ + "mappings": { + "properties": { + "my_vector": { + "type": "dense_vector", + "dims": 3, + "similarity": "dot_product", + } + } + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/360c4f373e72ba861584ee85bd218124.asciidoc b/docs/examples/360c4f373e72ba861584ee85bd218124.asciidoc new file mode 100644 index 000000000..3e11c6c84 --- /dev/null +++ b/docs/examples/360c4f373e72ba861584ee85bd218124.asciidoc @@ -0,0 +1,27 @@ +// mapping/types/percolator.asciidoc:262 + +[source, python] +---- +resp = client.indices.create( + index="test_index", + body={ + "settings": { + "analysis": { + "analyzer": { + "my_analyzer": { + "tokenizer": "standard", + "filter": ["lowercase", "porter_stem"], + } + } + } + }, + "mappings": { + "properties": { + "query": {"type": "percolator"}, + "body": {"type": "text", "analyzer": "my_analyzer"}, + } + }, + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/36962727b806315b221e8a63e05caddc.asciidoc b/docs/examples/36962727b806315b221e8a63e05caddc.asciidoc new file mode 100644 index 000000000..20d76e8ba --- /dev/null +++ b/docs/examples/36962727b806315b221e8a63e05caddc.asciidoc @@ -0,0 +1,12 @@ +// mapping/explicit-mapping.asciidoc:49 + +[source, python] +---- +resp = client.indices.put_mapping( + index="my-index-000001", + body={ + "properties": {"employee-id": {"type": "keyword", "index": False}} + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/36fae9dfc0b815546b45745bac054b67.asciidoc b/docs/examples/36fae9dfc0b815546b45745bac054b67.asciidoc new file mode 100644 index 000000000..d4cac7801 --- /dev/null +++ b/docs/examples/36fae9dfc0b815546b45745bac054b67.asciidoc @@ -0,0 +1,10 @@ +// mapping/runtime.asciidoc:496 + +[source, python] +---- +resp = client.search( + index="my-index-000001", + body={"query": {"match": {"model_number": "HG537PU"}}}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/3b0475515ee692a2d9850c2bd7cdb895.asciidoc b/docs/examples/3b0475515ee692a2d9850c2bd7cdb895.asciidoc new file mode 100644 index 000000000..0eea5d248 --- /dev/null +++ b/docs/examples/3b0475515ee692a2d9850c2bd7cdb895.asciidoc @@ -0,0 +1,27 @@ +// mapping/dynamic/templates.asciidoc:648 + +[source, python] +---- +resp = client.indices.create( + index="my-index-000001", + body={ + "mappings": { + "dynamic_templates": [ + { + "unindexed_longs": { + "match_mapping_type": "long", + "mapping": {"type": "long", "index": False}, + } + }, + { + "unindexed_doubles": { + "match_mapping_type": "double", + "mapping": {"type": "float", "index": False}, + } + }, + ] + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/3e13c8a81f40a537eddc0b57633b45f8.asciidoc b/docs/examples/3e13c8a81f40a537eddc0b57633b45f8.asciidoc new file mode 100644 index 000000000..baf074634 --- /dev/null +++ b/docs/examples/3e13c8a81f40a537eddc0b57633b45f8.asciidoc @@ -0,0 +1,10 @@ +// mapping/types/percolator.asciidoc:295 + +[source, python] +---- +resp = client.indices.analyze( + index="test_index", + body={"analyzer": "my_analyzer", "text": "missing bicycles"}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/3eb4cdd4a799a117ac1ff5f02b18a512.asciidoc b/docs/examples/3eb4cdd4a799a117ac1ff5f02b18a512.asciidoc new file mode 100644 index 000000000..8bc895c9b --- /dev/null +++ b/docs/examples/3eb4cdd4a799a117ac1ff5f02b18a512.asciidoc @@ -0,0 +1,30 @@ +// mapping/types/percolator.asciidoc:70 + +[source, python] +---- +resp = client.indices.create( + index="index", + body={ + "mappings": { + "properties": { + "query": {"type": "percolator"}, + "body": {"type": "text"}, + } + } + }, +) +print(resp) + +resp = client.indices.update_aliases( + body={"actions": [{"add": {"index": "index", "alias": "queries"}}]}, +) +print(resp) + +resp = client.index( + index="queries", + id="1", + refresh=True, + body={"query": {"match": {"body": "quick brown fox"}}}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/40d88d4f53343ef663c89ba488ab8001.asciidoc b/docs/examples/40d88d4f53343ef663c89ba488ab8001.asciidoc new file mode 100644 index 000000000..56962de87 --- /dev/null +++ b/docs/examples/40d88d4f53343ef663c89ba488ab8001.asciidoc @@ -0,0 +1,15 @@ +// mapping/types/shape.asciidoc:412 + +[source, python] +---- +resp = client.index( + index="example", + body={ + "location": { + "type": "envelope", + "coordinates": [[1000, 100], [1001, 100]], + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/413fdcc7c437775a16bb55b81c2bbe2b.asciidoc b/docs/examples/413fdcc7c437775a16bb55b81c2bbe2b.asciidoc new file mode 100644 index 000000000..5d917b1ec --- /dev/null +++ b/docs/examples/413fdcc7c437775a16bb55b81c2bbe2b.asciidoc @@ -0,0 +1,17 @@ +// mapping/runtime.asciidoc:1618 + +[source, python] +---- +resp = client.indices.put_mapping( + index="my-index-000001", + body={ + "runtime": { + "http.client.ip": { + "type": "ip", + "script": '\n String clientip=dissect(\'%{clientip} %{ident} %{auth} [%{@timestamp}] "%{verb} %{request} HTTP/%{httpversion}" %{status} %{size}\').extract(doc["message"].value)?.clientip;\n if (clientip != null) emit(clientip);\n ', + } + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/435e0d6a7d86e074d572d9671b7b9676.asciidoc b/docs/examples/435e0d6a7d86e074d572d9671b7b9676.asciidoc new file mode 100644 index 000000000..2401940db --- /dev/null +++ b/docs/examples/435e0d6a7d86e074d572d9671b7b9676.asciidoc @@ -0,0 +1,17 @@ +// mapping/types/geo-shape.asciidoc:227 + +[source, python] +---- +resp = client.index( + index="example", + body={ + "location": { + "type": "Polygon", + "coordinates": [ + [[100, 0], [101, 0], [101, 1], [100, 1], [100, 0]] + ], + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/445f8a6ef75fb43da52990b3a9063c78.asciidoc b/docs/examples/445f8a6ef75fb43da52990b3a9063c78.asciidoc new file mode 100644 index 000000000..856f4780a --- /dev/null +++ b/docs/examples/445f8a6ef75fb43da52990b3a9063c78.asciidoc @@ -0,0 +1,13 @@ +// mapping/runtime.asciidoc:1658 + +[source, python] +---- +resp = client.search( + index="my-index-000001", + body={ + "query": {"match": {"http.responses": "304"}}, + "fields": ["http.client_ip", "timestamp", "http.verb"], + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/45499ed1824d1d7cb59972580d2344cb.asciidoc b/docs/examples/45499ed1824d1d7cb59972580d2344cb.asciidoc new file mode 100644 index 000000000..a071af1a1 --- /dev/null +++ b/docs/examples/45499ed1824d1d7cb59972580d2344cb.asciidoc @@ -0,0 +1,19 @@ +// mapping/types/unsigned_long.asciidoc:68 + +[source, python] +---- +resp = client.search( + index="my_index", + body={ + "query": { + "range": { + "my_counter": { + "gte": "9223372036854775808", + "lte": "18446744073709551615", + } + } + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/45813d971bfa890ffa2f51f3f480cce5.asciidoc b/docs/examples/45813d971bfa890ffa2f51f3f480cce5.asciidoc new file mode 100644 index 000000000..cb6cefd6d --- /dev/null +++ b/docs/examples/45813d971bfa890ffa2f51f3f480cce5.asciidoc @@ -0,0 +1,17 @@ +// mapping/types/percolator.asciidoc:355 + +[source, python] +---- +resp = client.search( + index="test_index", + body={ + "query": { + "percolate": { + "field": "query", + "document": {"body": "Bycicles are missing"}, + } + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/484e24d1ed1a154ba9753e6090d38d78.asciidoc b/docs/examples/484e24d1ed1a154ba9753e6090d38d78.asciidoc new file mode 100644 index 000000000..3391f5bf1 --- /dev/null +++ b/docs/examples/484e24d1ed1a154ba9753e6090d38d78.asciidoc @@ -0,0 +1,15 @@ +// mapping/types/shape.asciidoc:140 + +[source, python] +---- +resp = client.index( + index="example", + body={ + "location": { + "type": "point", + "coordinates": [-377.03653, 389.897676], + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/4aa81a694266fb634904224d14cd9a87.asciidoc b/docs/examples/4aa81a694266fb634904224d14cd9a87.asciidoc new file mode 100644 index 000000000..c4365adfd --- /dev/null +++ b/docs/examples/4aa81a694266fb634904224d14cd9a87.asciidoc @@ -0,0 +1,17 @@ +// mapping/types/percolator.asciidoc:668 + +[source, python] +---- +resp = client.search( + index="my_queries2", + body={ + "query": { + "percolate": { + "field": "query", + "document": {"my_field": "wxyz"}, + } + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/4be07b34db282044c88d5021c7ea08ee.asciidoc b/docs/examples/4be07b34db282044c88d5021c7ea08ee.asciidoc new file mode 100644 index 000000000..5692f1cbc --- /dev/null +++ b/docs/examples/4be07b34db282044c88d5021c7ea08ee.asciidoc @@ -0,0 +1,31 @@ +// mapping/types/dense-vector.asciidoc:18 + +[source, python] +---- +resp = client.indices.create( + index="my-index", + body={ + "mappings": { + "properties": { + "my_vector": {"type": "dense_vector", "dims": 3}, + "my_text": {"type": "keyword"}, + } + } + }, +) +print(resp) + +resp = client.index( + index="my-index", + id="1", + body={"my_text": "text1", "my_vector": [0.5, 10, 6]}, +) +print(resp) + +resp = client.index( + index="my-index", + id="2", + body={"my_text": "text2", "my_vector": [-0.5, 10, 10]}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/4c95d54b32df4dc49e9762b6c1ae2c05.asciidoc b/docs/examples/4c95d54b32df4dc49e9762b6c1ae2c05.asciidoc new file mode 100644 index 000000000..120629a54 --- /dev/null +++ b/docs/examples/4c95d54b32df4dc49e9762b6c1ae2c05.asciidoc @@ -0,0 +1,24 @@ +// mapping/types/text.asciidoc:353 + +[source, python] +---- +resp = client.indices.create( + index="my-index-000001", + body={ + "mappings": { + "properties": { + "tag": { + "type": "text", + "fielddata": True, + "fielddata_frequency_filter": { + "min": 0.001, + "max": 0.1, + "min_segment_size": 500, + }, + } + } + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/4f1e1205154d280db21fbd2754ed5398.asciidoc b/docs/examples/4f1e1205154d280db21fbd2754ed5398.asciidoc new file mode 100644 index 000000000..305d4b18f --- /dev/null +++ b/docs/examples/4f1e1205154d280db21fbd2754ed5398.asciidoc @@ -0,0 +1,20 @@ +// mapping/types/aggregate-metric-double.asciidoc:114 + +[source, python] +---- +resp = client.indices.create( + index="stats-index", + body={ + "mappings": { + "properties": { + "agg_metric": { + "type": "aggregate_metric_double", + "metrics": ["min", "max", "sum", "value_count"], + "default_metric": "max", + } + } + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/4f792d86ff79dcfe4643cd95505f8d5f.asciidoc b/docs/examples/4f792d86ff79dcfe4643cd95505f8d5f.asciidoc new file mode 100644 index 000000000..4551d8004 --- /dev/null +++ b/docs/examples/4f792d86ff79dcfe4643cd95505f8d5f.asciidoc @@ -0,0 +1,23 @@ +// mapping/runtime.asciidoc:661 + +[source, python] +---- +resp = client.indices.create( + index="my-index-000001", + body={ + "mappings": { + "dynamic": "runtime", + "runtime": { + "day_of_week": { + "type": "keyword", + "script": { + "source": "emit(doc['@timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT))" + }, + } + }, + "properties": {"@timestamp": {"type": "date"}}, + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/4fe78a4dfb747fd5dc34145ec6b76183.asciidoc b/docs/examples/4fe78a4dfb747fd5dc34145ec6b76183.asciidoc new file mode 100644 index 000000000..d5f60c81c --- /dev/null +++ b/docs/examples/4fe78a4dfb747fd5dc34145ec6b76183.asciidoc @@ -0,0 +1,22 @@ +// mapping/runtime.asciidoc:130 + +[source, python] +---- +resp = client.indices.create( + index="my-index-000001", + body={ + "mappings": { + "runtime": { + "day_of_week": { + "type": "keyword", + "script": { + "source": "emit(doc['@timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT))" + }, + } + }, + "properties": {"@timestamp": {"type": "date"}}, + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/50522d3d5b3d055f712ad737e3d1707a.asciidoc b/docs/examples/50522d3d5b3d055f712ad737e3d1707a.asciidoc new file mode 100644 index 000000000..9cf7f2175 --- /dev/null +++ b/docs/examples/50522d3d5b3d055f712ad737e3d1707a.asciidoc @@ -0,0 +1,44 @@ +// mapping/types/token-count.asciidoc:14 + +[source, python] +---- +resp = client.indices.create( + index="my-index-000001", + body={ + "mappings": { + "properties": { + "name": { + "type": "text", + "fields": { + "length": { + "type": "token_count", + "analyzer": "standard", + } + }, + } + } + } + }, +) +print(resp) + +resp = client.index( + index="my-index-000001", + id="1", + body={"name": "John Smith"}, +) +print(resp) + +resp = client.index( + index="my-index-000001", + id="2", + body={"name": "Rachel Alice Williams"}, +) +print(resp) + +resp = client.search( + index="my-index-000001", + body={"query": {"term": {"name.length": 3}}}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/529b975b7cedaac58dce9821956adc37.asciidoc b/docs/examples/529b975b7cedaac58dce9821956adc37.asciidoc new file mode 100644 index 000000000..fd6388a57 --- /dev/null +++ b/docs/examples/529b975b7cedaac58dce9821956adc37.asciidoc @@ -0,0 +1,27 @@ +// mapping/types/geo-shape.asciidoc:391 + +[source, python] +---- +resp = client.index( + index="example", + body={ + "location": { + "type": "MultiPolygon", + "coordinates": [ + [[[102, 2], [103, 2], [103, 3], [102, 3], [102, 2]]], + [ + [[100, 0], [101, 0], [101, 1], [100, 1], [100, 0]], + [ + [100.2, 0.2], + [100.8, 0.2], + [100.8, 0.8], + [100.2, 0.8], + [100.2, 0.2], + ], + ], + ], + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/5332c4cca5fbb45cc700dcd34f37bc38.asciidoc b/docs/examples/5332c4cca5fbb45cc700dcd34f37bc38.asciidoc new file mode 100644 index 000000000..2c1ec87f1 --- /dev/null +++ b/docs/examples/5332c4cca5fbb45cc700dcd34f37bc38.asciidoc @@ -0,0 +1,11 @@ +// mapping/dynamic/templates.asciidoc:557 + +[source, python] +---- +resp = client.index( + index="my-index-000001", + id="1", + body={"english": "Some English text", "count": 5}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/57c690f8fa95bacf4b250803be7467e4.asciidoc b/docs/examples/57c690f8fa95bacf4b250803be7467e4.asciidoc new file mode 100644 index 000000000..75d7bfb86 --- /dev/null +++ b/docs/examples/57c690f8fa95bacf4b250803be7467e4.asciidoc @@ -0,0 +1,10 @@ +// mapping/types/shape.asciidoc:427 + +[source, python] +---- +resp = client.index( + index="example", + body={"location": "BBOX (1000.0, 1002.0, 2000.0, 1000.0)"}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/585b19369cb9b9763a7e8d405f009a47.asciidoc b/docs/examples/585b19369cb9b9763a7e8d405f009a47.asciidoc new file mode 100644 index 000000000..7ec0673b0 --- /dev/null +++ b/docs/examples/585b19369cb9b9763a7e8d405f009a47.asciidoc @@ -0,0 +1,10 @@ +// mapping/runtime.asciidoc:249 + +[source, python] +---- +resp = client.indices.put_mapping( + index="my-index-000001", + body={"runtime": {"day_of_week": None}}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/5a006feed86309b547bbaa1baca1c496.asciidoc b/docs/examples/5a006feed86309b547bbaa1baca1c496.asciidoc new file mode 100644 index 000000000..386f4b545 --- /dev/null +++ b/docs/examples/5a006feed86309b547bbaa1baca1c496.asciidoc @@ -0,0 +1,64 @@ +// mapping/dynamic/templates.asciidoc:148 + +[source, python] +---- +resp = client.indices.create( + index="my-index-000001", + body={ + "mappings": { + "dynamic_templates": [ + { + "numeric_counts": { + "match_mapping_type": ["long", "double"], + "match": "count", + "mapping": { + "type": "{dynamic_type}", + "index": False, + }, + } + }, + { + "integers": { + "match_mapping_type": "long", + "mapping": {"type": "integer"}, + } + }, + { + "strings": { + "match_mapping_type": "string", + "mapping": { + "type": "text", + "fields": { + "raw": { + "type": "keyword", + "ignore_above": 256, + } + }, + }, + } + }, + { + "non_objects_keyword": { + "match_mapping_type": "*", + "unmatch_mapping_type": "object", + "mapping": {"type": "keyword"}, + } + }, + ] + } + }, +) +print(resp) + +resp = client.index( + index="my-index-000001", + id="1", + body={ + "my_integer": 5, + "my_string": "Some string", + "my_boolean": "false", + "field": {"count": 4}, + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/5b8119b4d9a09f4643be5a5b40875c8f.asciidoc b/docs/examples/5b8119b4d9a09f4643be5a5b40875c8f.asciidoc new file mode 100644 index 000000000..b5987aba5 --- /dev/null +++ b/docs/examples/5b8119b4d9a09f4643be5a5b40875c8f.asciidoc @@ -0,0 +1,36 @@ +// mapping/types/boolean.asciidoc:78 + +[source, python] +---- +resp = client.index( + index="my-index-000001", + id="1", + refresh=True, + body={"is_published": True}, +) +print(resp) + +resp = client.index( + index="my-index-000001", + id="2", + refresh=True, + body={"is_published": False}, +) +print(resp) + +resp = client.search( + index="my-index-000001", + body={ + "aggs": {"publish_state": {"terms": {"field": "is_published"}}}, + "sort": ["is_published"], + "fields": [{"field": "weight"}], + "runtime_mappings": { + "weight": { + "type": "long", + "script": "emit(doc['is_published'].value ? 10 : 0)", + } + }, + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/5b86d54900e2c4c043a54ca7ae2df0f0.asciidoc b/docs/examples/5b86d54900e2c4c043a54ca7ae2df0f0.asciidoc new file mode 100644 index 000000000..fff85f1f4 --- /dev/null +++ b/docs/examples/5b86d54900e2c4c043a54ca7ae2df0f0.asciidoc @@ -0,0 +1,22 @@ +// mapping/types/flattened.asciidoc:407 + +[source, python] +---- +resp = client.indices.create( + index="idx", + body={ + "mappings": { + "_source": {"mode": "synthetic"}, + "properties": {"flattened": {"type": "flattened"}}, + } + }, +) +print(resp) + +resp = client.index( + index="idx", + id="1", + body={"flattened": {"field": ["foo"]}}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/60cab62af1540db2ad3b696b0ee1d7a8.asciidoc b/docs/examples/60cab62af1540db2ad3b696b0ee1d7a8.asciidoc new file mode 100644 index 000000000..0c5d1ad7f --- /dev/null +++ b/docs/examples/60cab62af1540db2ad3b696b0ee1d7a8.asciidoc @@ -0,0 +1,17 @@ +// mapping/types/percolator.asciidoc:165 + +[source, python] +---- +resp = client.search( + index="queries", + body={ + "query": { + "percolate": { + "field": "query", + "document": {"body": "fox jumps over the lazy dog"}, + } + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/61c49cee90c6aa0eafbdd5cc03936e7d.asciidoc b/docs/examples/61c49cee90c6aa0eafbdd5cc03936e7d.asciidoc new file mode 100644 index 000000000..ff89fcb84 --- /dev/null +++ b/docs/examples/61c49cee90c6aa0eafbdd5cc03936e7d.asciidoc @@ -0,0 +1,11 @@ +// mapping/dynamic-mapping.asciidoc:11 + +[source, python] +---- +resp = client.index( + index="data", + id="1", + body={"count": 5}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/636ee2066450605247ec1f68d04b8ee4.asciidoc b/docs/examples/636ee2066450605247ec1f68d04b8ee4.asciidoc new file mode 100644 index 000000000..9fa46eb89 --- /dev/null +++ b/docs/examples/636ee2066450605247ec1f68d04b8ee4.asciidoc @@ -0,0 +1,13 @@ +// mapping/runtime.asciidoc:1467 + +[source, python] +---- +resp = client.search( + index="my-index-000001", + body={ + "query": {"match": {"http.clientip": "40.135.0.0"}}, + "fields": ["*"], + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/643b9506d1129d5215f9a1bb0b509aba.asciidoc b/docs/examples/643b9506d1129d5215f9a1bb0b509aba.asciidoc new file mode 100644 index 000000000..82c8e36d8 --- /dev/null +++ b/docs/examples/643b9506d1129d5215f9a1bb0b509aba.asciidoc @@ -0,0 +1,34 @@ +// mapping/dynamic/templates.asciidoc:316 + +[source, python] +---- +resp = client.indices.create( + index="my-index-000001", + body={ + "mappings": { + "dynamic_templates": [ + { + "full_name": { + "path_match": "name.*", + "path_unmatch": "*.middle", + "mapping": { + "type": "text", + "copy_to": "full_name", + }, + } + } + ] + } + }, +) +print(resp) + +resp = client.index( + index="my-index-000001", + id="1", + body={ + "name": {"first": "John", "middle": "Winston", "last": "Lennon"} + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/6a9655fe22fa5db7a540c145bcf1fb31.asciidoc b/docs/examples/6a9655fe22fa5db7a540c145bcf1fb31.asciidoc new file mode 100644 index 000000000..349a3c0e6 --- /dev/null +++ b/docs/examples/6a9655fe22fa5db7a540c145bcf1fb31.asciidoc @@ -0,0 +1,32 @@ +// mapping/types/aggregate-metric-double.asciidoc:133 + +[source, python] +---- +resp = client.index( + index="stats-index", + id="1", + body={ + "agg_metric": { + "min": -302.5, + "max": 702.3, + "sum": 200, + "value_count": 25, + } + }, +) +print(resp) + +resp = client.index( + index="stats-index", + id="2", + body={ + "agg_metric": { + "min": -93, + "max": 1702.3, + "sum": 300, + "value_count": 25, + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/6db118771354792646229e7a3c30c7e9.asciidoc b/docs/examples/6db118771354792646229e7a3c30c7e9.asciidoc new file mode 100644 index 000000000..0e6e04a74 --- /dev/null +++ b/docs/examples/6db118771354792646229e7a3c30c7e9.asciidoc @@ -0,0 +1,54 @@ +// mapping/runtime.asciidoc:993 + +[source, python] +---- +resp = client.bulk( + index="my-index-000001", + refresh="true", + body=[ + {"index": {}}, + { + "timestamp": 1516729294000, + "temperature": 200, + "voltage": 5.2, + "node": "a", + }, + {"index": {}}, + { + "timestamp": 1516642894000, + "temperature": 201, + "voltage": 5.8, + "node": "b", + }, + {"index": {}}, + { + "timestamp": 1516556494000, + "temperature": 202, + "voltage": 5.1, + "node": "a", + }, + {"index": {}}, + { + "timestamp": 1516470094000, + "temperature": 198, + "voltage": 5.6, + "node": "b", + }, + {"index": {}}, + { + "timestamp": 1516383694000, + "temperature": 200, + "voltage": 4.2, + "node": "c", + }, + {"index": {}}, + { + "timestamp": 1516297294000, + "temperature": 202, + "voltage": 4, + "node": "c", + }, + ], +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/6e1ae8d6103e0b77f14fb0ea1bfb7ffa.asciidoc b/docs/examples/6e1ae8d6103e0b77f14fb0ea1bfb7ffa.asciidoc new file mode 100644 index 000000000..ceaaad117 --- /dev/null +++ b/docs/examples/6e1ae8d6103e0b77f14fb0ea1bfb7ffa.asciidoc @@ -0,0 +1,12 @@ +// mapping/types/shape.asciidoc:397 + +[source, python] +---- +resp = client.index( + index="example", + body={ + "location": "GEOMETRYCOLLECTION (POINT (1000.0 100.0), LINESTRING (1001.0 100.0, 1002.0 100.0))" + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/6f6d5a4a90e1265822628d4ced963639.asciidoc b/docs/examples/6f6d5a4a90e1265822628d4ced963639.asciidoc new file mode 100644 index 000000000..85a25d536 --- /dev/null +++ b/docs/examples/6f6d5a4a90e1265822628d4ced963639.asciidoc @@ -0,0 +1,16 @@ +// mapping/dynamic/field-mapping.asciidoc:63 + +[source, python] +---- +resp = client.index( + index="my-index-000001", + id="1", + body={"create_date": "2015/09/02"}, +) +print(resp) + +resp = client.indices.get_mapping( + index="my-index-000001", +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/6fbbf40cab0187f544ff7bca31d18d57.asciidoc b/docs/examples/6fbbf40cab0187f544ff7bca31d18d57.asciidoc new file mode 100644 index 000000000..bc9a445fa --- /dev/null +++ b/docs/examples/6fbbf40cab0187f544ff7bca31d18d57.asciidoc @@ -0,0 +1,24 @@ +// mapping/types/geo-shape.asciidoc:254 + +[source, python] +---- +resp = client.index( + index="example", + body={ + "location": { + "type": "Polygon", + "coordinates": [ + [[100, 0], [101, 0], [101, 1], [100, 1], [100, 0]], + [ + [100.2, 0.2], + [100.8, 0.2], + [100.8, 0.8], + [100.2, 0.8], + [100.2, 0.2], + ], + ], + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/6fd82baa17a48e09e3d2eed514af7f46.asciidoc b/docs/examples/6fd82baa17a48e09e3d2eed514af7f46.asciidoc new file mode 100644 index 000000000..31f92441f --- /dev/null +++ b/docs/examples/6fd82baa17a48e09e3d2eed514af7f46.asciidoc @@ -0,0 +1,19 @@ +// mapping/types/geo-shape.asciidoc:360 + +[source, python] +---- +resp = client.index( + index="example", + body={ + "location": { + "type": "MultiLineString", + "coordinates": [ + [[102, 2], [103, 2], [103, 3], [102, 3]], + [[100, 0], [101, 0], [101, 1], [100, 1]], + [[100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8]], + ], + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/7011fcdd231804f9c3894154ae2c3fbc.asciidoc b/docs/examples/7011fcdd231804f9c3894154ae2c3fbc.asciidoc new file mode 100644 index 000000000..b80035dba --- /dev/null +++ b/docs/examples/7011fcdd231804f9c3894154ae2c3fbc.asciidoc @@ -0,0 +1,14 @@ +// mapping/types/sparse-vector.asciidoc:13 + +[source, python] +---- +resp = client.indices.create( + index="my-index", + body={ + "mappings": { + "properties": {"text.tokens": {"type": "sparse_vector"}} + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/77d0780c5faea4c9ec51a322a6811b3b.asciidoc b/docs/examples/77d0780c5faea4c9ec51a322a6811b3b.asciidoc new file mode 100644 index 000000000..3bbb89e7e --- /dev/null +++ b/docs/examples/77d0780c5faea4c9ec51a322a6811b3b.asciidoc @@ -0,0 +1,47 @@ +// mapping/runtime.asciidoc:1311 + +[source, python] +---- +resp = client.bulk( + index="my-index-000001", + refresh=True, + body=[ + {"index": {}}, + { + "timestamp": "2020-04-30T14:30:17-05:00", + "message": '40.135.0.0 - - [30/Apr/2020:14:30:17 -0500] "GET /images/hm_bg.jpg HTTP/1.0" 200 24736', + }, + {"index": {}}, + { + "timestamp": "2020-04-30T14:30:53-05:00", + "message": '232.0.0.0 - - [30/Apr/2020:14:30:53 -0500] "GET /images/hm_bg.jpg HTTP/1.0" 200 24736', + }, + {"index": {}}, + { + "timestamp": "2020-04-30T14:31:12-05:00", + "message": '26.1.0.0 - - [30/Apr/2020:14:31:12 -0500] "GET /images/hm_bg.jpg HTTP/1.0" 200 24736', + }, + {"index": {}}, + { + "timestamp": "2020-04-30T14:31:19-05:00", + "message": '247.37.0.0 - - [30/Apr/2020:14:31:19 -0500] "GET /french/splash_inet.html HTTP/1.0" 200 3781', + }, + {"index": {}}, + { + "timestamp": "2020-04-30T14:31:22-05:00", + "message": '247.37.0.0 - - [30/Apr/2020:14:31:22 -0500] "GET /images/hm_nbg.jpg HTTP/1.0" 304 0', + }, + {"index": {}}, + { + "timestamp": "2020-04-30T14:31:27-05:00", + "message": '252.0.0.0 - - [30/Apr/2020:14:31:27 -0500] "GET /images/hm_bg.jpg HTTP/1.0" 200 24736', + }, + {"index": {}}, + { + "timestamp": "2020-04-30T14:31:28-05:00", + "message": "not a valid apache log", + }, + ], +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/79e8bbbd6c440a21b0b4260c8cb1a61c.asciidoc b/docs/examples/79e8bbbd6c440a21b0b4260c8cb1a61c.asciidoc new file mode 100644 index 000000000..0126f7231 --- /dev/null +++ b/docs/examples/79e8bbbd6c440a21b0b4260c8cb1a61c.asciidoc @@ -0,0 +1,12 @@ +// mapping/types/geo-shape.asciidoc:208 + +[source, python] +---- +resp = client.index( + index="example", + body={ + "location": "LINESTRING (-77.03653 38.897676, -77.009051 38.889939)" + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/7a0eb2222fe282d3aab66e12feff2a3b.asciidoc b/docs/examples/7a0eb2222fe282d3aab66e12feff2a3b.asciidoc new file mode 100644 index 000000000..ee3d7efb2 --- /dev/null +++ b/docs/examples/7a0eb2222fe282d3aab66e12feff2a3b.asciidoc @@ -0,0 +1,45 @@ +// mapping/runtime.asciidoc:834 + +[source, python] +---- +resp = client.index( + index="ip_location", + refresh=True, + body={"ip": "192.168.1.1", "country": "Canada", "city": "Montreal"}, +) +print(resp) + +resp = client.index( + index="logs", + id="1", + refresh=True, + body={"host": "192.168.1.1", "message": "the first message"}, +) +print(resp) + +resp = client.index( + index="logs", + id="2", + refresh=True, + body={"host": "192.168.1.2", "message": "the second message"}, +) +print(resp) + +resp = client.search( + index="logs", + body={ + "runtime_mappings": { + "location": { + "type": "lookup", + "target_index": "ip_location", + "input_field": "host", + "target_field": "ip", + "fetch_fields": ["country", "city"], + } + }, + "fields": ["host", "message", "location"], + "_source": False, + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/7a2b9a7b2b6553a48bd4db60a939c0fc.asciidoc b/docs/examples/7a2b9a7b2b6553a48bd4db60a939c0fc.asciidoc new file mode 100644 index 000000000..ad131f0e2 --- /dev/null +++ b/docs/examples/7a2b9a7b2b6553a48bd4db60a939c0fc.asciidoc @@ -0,0 +1,18 @@ +// mapping/types/percolator.asciidoc:331 + +[source, python] +---- +resp = client.index( + index="test_index", + id="1", + refresh=True, + body={ + "query": { + "match": { + "body": {"query": "miss bicycl", "analyzer": "whitespace"} + } + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/7c24d4bef3f2045407fbf1b95c5416f9.asciidoc b/docs/examples/7c24d4bef3f2045407fbf1b95c5416f9.asciidoc new file mode 100644 index 000000000..c81cdbf3f --- /dev/null +++ b/docs/examples/7c24d4bef3f2045407fbf1b95c5416f9.asciidoc @@ -0,0 +1,32 @@ +// mapping/types/range.asciidoc:34 + +[source, python] +---- +resp = client.indices.create( + index="range_index", + body={ + "settings": {"number_of_shards": 2}, + "mappings": { + "properties": { + "expected_attendees": {"type": "integer_range"}, + "time_frame": { + "type": "date_range", + "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis", + }, + } + }, + }, +) +print(resp) + +resp = client.index( + index="range_index", + id="1", + refresh=True, + body={ + "expected_attendees": {"gte": 10, "lt": 20}, + "time_frame": {"gte": "2015-10-31 12:00:00", "lte": "2015-11-01"}, + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/7e16d21cba51eb8960835b63a1a7266a.asciidoc b/docs/examples/7e16d21cba51eb8960835b63a1a7266a.asciidoc new file mode 100644 index 000000000..58a4f4a7e --- /dev/null +++ b/docs/examples/7e16d21cba51eb8960835b63a1a7266a.asciidoc @@ -0,0 +1,17 @@ +// mapping/dynamic/field-mapping.asciidoc:103 + +[source, python] +---- +resp = client.indices.create( + index="my-index-000001", + body={"mappings": {"dynamic_date_formats": ["MM/dd/yyyy"]}}, +) +print(resp) + +resp = client.index( + index="my-index-000001", + id="1", + body={"create_date": "09/25/2015"}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/7f514e9e785e4323d16396359cb184f2.asciidoc b/docs/examples/7f514e9e785e4323d16396359cb184f2.asciidoc new file mode 100644 index 000000000..c6a25cd9f --- /dev/null +++ b/docs/examples/7f514e9e785e4323d16396359cb184f2.asciidoc @@ -0,0 +1,17 @@ +// mapping/types/range.asciidoc:195 + +[source, python] +---- +resp = client.indices.put_mapping( + index="range_index", + body={"properties": {"ip_allowlist": {"type": "ip_range"}}}, +) +print(resp) + +resp = client.index( + index="range_index", + id="2", + body={"ip_allowlist": "192.168.0.0/16"}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/7f92ddd4e940a37d6227c43fd279c8f5.asciidoc b/docs/examples/7f92ddd4e940a37d6227c43fd279c8f5.asciidoc new file mode 100644 index 000000000..a88e9d737 --- /dev/null +++ b/docs/examples/7f92ddd4e940a37d6227c43fd279c8f5.asciidoc @@ -0,0 +1,14 @@ +// mapping/runtime.asciidoc:759 + +[source, python] +---- +resp = client.search( + index="my-index-000001", + body={ + "size": 1, + "query": {"match": {"client_ip": "211.11.9.0"}}, + "fields": ["*"], + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/82e94b6cdf65e324575f916b3776b779.asciidoc b/docs/examples/82e94b6cdf65e324575f916b3776b779.asciidoc new file mode 100644 index 000000000..47f9753d8 --- /dev/null +++ b/docs/examples/82e94b6cdf65e324575f916b3776b779.asciidoc @@ -0,0 +1,21 @@ +// mapping/dynamic/templates.asciidoc:538 + +[source, python] +---- +resp = client.indices.create( + index="my-index-000001", + body={ + "mappings": { + "dynamic_templates": [ + { + "strings_as_keywords": { + "match_mapping_type": "string", + "runtime": {}, + } + } + ] + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/84243213614fe64930b1d430704afb29.asciidoc b/docs/examples/84243213614fe64930b1d430704afb29.asciidoc new file mode 100644 index 000000000..fe5017cf2 --- /dev/null +++ b/docs/examples/84243213614fe64930b1d430704afb29.asciidoc @@ -0,0 +1,20 @@ +// mapping/runtime.asciidoc:1016 + +[source, python] +---- +resp = client.indices.put_mapping( + index="my-index-000001", + body={ + "runtime": { + "voltage_corrected": { + "type": "double", + "script": { + "source": "\n emit(doc['voltage'].value * params['multiplier'])\n ", + "params": {"multiplier": 2}, + }, + } + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/84edb44c5b74426f448b2baa101092d6.asciidoc b/docs/examples/84edb44c5b74426f448b2baa101092d6.asciidoc new file mode 100644 index 000000000..70c294679 --- /dev/null +++ b/docs/examples/84edb44c5b74426f448b2baa101092d6.asciidoc @@ -0,0 +1,10 @@ +// mapping/types/range.asciidoc:75 + +[source, python] +---- +resp = client.search( + index="range_index", + body={"query": {"term": {"expected_attendees": {"value": 12}}}}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/850bfd0a00d32475a54ac7f87fb4cc4d.asciidoc b/docs/examples/850bfd0a00d32475a54ac7f87fb4cc4d.asciidoc new file mode 100644 index 000000000..ff04f392e --- /dev/null +++ b/docs/examples/850bfd0a00d32475a54ac7f87fb4cc4d.asciidoc @@ -0,0 +1,21 @@ +// mapping/runtime.asciidoc:563 + +[source, python] +---- +resp = client.search( + index="my-index-000001", + body={ + "runtime_mappings": { + "measures.voltage": { + "type": "double", + "script": { + "source": "if (doc['model_number.keyword'].value.equals('HG537PU'))\n {emit(1.7 * params._source['measures']['voltage']);}\n else{emit(params._source['measures']['voltage']);}" + }, + } + }, + "query": {"match": {"model_number": "HG537PU"}}, + "fields": ["measures.voltage"], + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/858fde15fb0a0340873b123043f8c3b4.asciidoc b/docs/examples/858fde15fb0a0340873b123043f8c3b4.asciidoc new file mode 100644 index 000000000..d8c3420af --- /dev/null +++ b/docs/examples/858fde15fb0a0340873b123043f8c3b4.asciidoc @@ -0,0 +1,30 @@ +// mapping/types/histogram.asciidoc:119 + +[source, python] +---- +resp = client.index( + index="my-index-000001", + id="1", + body={ + "my_text": "histogram_1", + "my_histogram": { + "values": [0.1, 0.2, 0.3, 0.4, 0.5], + "counts": [3, 7, 23, 12, 6], + }, + }, +) +print(resp) + +resp = client.index( + index="my-index-000001", + id="2", + body={ + "my_text": "histogram_2", + "my_histogram": { + "values": [0.1, 0.25, 0.35, 0.4, 0.45, 0.5], + "counts": [8, 17, 8, 7, 6, 2], + }, + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/86926bcebf213ac182d4373027554858.asciidoc b/docs/examples/86926bcebf213ac182d4373027554858.asciidoc new file mode 100644 index 000000000..dc01a99a5 --- /dev/null +++ b/docs/examples/86926bcebf213ac182d4373027554858.asciidoc @@ -0,0 +1,14 @@ +// mapping/types/unsigned_long.asciidoc:13 + +[source, python] +---- +resp = client.indices.create( + index="my_index", + body={ + "mappings": { + "properties": {"my_counter": {"type": "unsigned_long"}} + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/86c5594c4ec551391096c1abcd652b50.asciidoc b/docs/examples/86c5594c4ec551391096c1abcd652b50.asciidoc new file mode 100644 index 000000000..be45acd14 --- /dev/null +++ b/docs/examples/86c5594c4ec551391096c1abcd652b50.asciidoc @@ -0,0 +1,19 @@ +// mapping/types/unsigned_long.asciidoc:125 + +[source, python] +---- +resp = client.search( + index="my_index", + body={ + "query": {"match_all": {}}, + "script_fields": { + "count10": { + "script": { + "source": "Long.divideUnsigned(doc['my_counter'].value, 10)" + } + } + }, + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/8aa74aee3dcf4b34028e4c5e1c1ed27b.asciidoc b/docs/examples/8aa74aee3dcf4b34028e4c5e1c1ed27b.asciidoc new file mode 100644 index 000000000..0715de378 --- /dev/null +++ b/docs/examples/8aa74aee3dcf4b34028e4c5e1c1ed27b.asciidoc @@ -0,0 +1,31 @@ +// mapping/types/flattened.asciidoc:35 + +[source, python] +---- +resp = client.indices.create( + index="bug_reports", + body={ + "mappings": { + "properties": { + "title": {"type": "text"}, + "labels": {"type": "flattened"}, + } + } + }, +) +print(resp) + +resp = client.index( + index="bug_reports", + id="1", + body={ + "title": "Results are not sorted correctly.", + "labels": { + "priority": "urgent", + "release": ["v1.2.5", "v1.3.0"], + "timestamp": {"created": 1541458026, "closed": 1541457010}, + }, + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/8b07372a21a10a16b52e70fc0c87ad4e.asciidoc b/docs/examples/8b07372a21a10a16b52e70fc0c87ad4e.asciidoc new file mode 100644 index 000000000..e2b27ba5d --- /dev/null +++ b/docs/examples/8b07372a21a10a16b52e70fc0c87ad4e.asciidoc @@ -0,0 +1,14 @@ +// mapping/types/object.asciidoc:11 + +[source, python] +---- +resp = client.index( + index="my-index-000001", + id="1", + body={ + "region": "US", + "manager": {"age": 30, "name": {"first": "John", "last": "Smith"}}, + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/8bf51fd50195b46bacbf872f460ebec2.asciidoc b/docs/examples/8bf51fd50195b46bacbf872f460ebec2.asciidoc new file mode 100644 index 000000000..61d212e25 --- /dev/null +++ b/docs/examples/8bf51fd50195b46bacbf872f460ebec2.asciidoc @@ -0,0 +1,31 @@ +// mapping/types/version.asciidoc:86 + +[source, python] +---- +resp = client.indices.create( + index="idx", + body={ + "mappings": { + "_source": {"mode": "synthetic"}, + "properties": {"versions": {"type": "version"}}, + } + }, +) +print(resp) + +resp = client.index( + index="idx", + id="1", + body={ + "versions": [ + "8.0.0-beta1", + "8.5.0", + "0.90.12", + "2.6.1", + "1.3.4", + "1.3.4", + ] + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/8c693e057f6e85fbf2b56ca442719362.asciidoc b/docs/examples/8c693e057f6e85fbf2b56ca442719362.asciidoc new file mode 100644 index 000000000..759ca1452 --- /dev/null +++ b/docs/examples/8c693e057f6e85fbf2b56ca442719362.asciidoc @@ -0,0 +1,19 @@ +// mapping/types/aggregate-metric-double.asciidoc:161 + +[source, python] +---- +resp = client.search( + index="stats-index", + size="0", + body={ + "aggs": { + "metric_min": {"min": {"field": "agg_metric"}}, + "metric_max": {"max": {"field": "agg_metric"}}, + "metric_value_count": {"value_count": {"field": "agg_metric"}}, + "metric_sum": {"sum": {"field": "agg_metric"}}, + "metric_avg": {"avg": {"field": "agg_metric"}}, + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/8c92c5e87facbae8dc4f58376ec21815.asciidoc b/docs/examples/8c92c5e87facbae8dc4f58376ec21815.asciidoc new file mode 100644 index 000000000..488d20841 --- /dev/null +++ b/docs/examples/8c92c5e87facbae8dc4f58376ec21815.asciidoc @@ -0,0 +1,10 @@ +// mapping/runtime.asciidoc:1040 + +[source, python] +---- +resp = client.search( + index="my-index-000001", + body={"fields": ["voltage_corrected", "node"], "size": 2}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/8e68cdfad45e7e6dff254d931eea29d4.asciidoc b/docs/examples/8e68cdfad45e7e6dff254d931eea29d4.asciidoc new file mode 100644 index 000000000..bdc078a68 --- /dev/null +++ b/docs/examples/8e68cdfad45e7e6dff254d931eea29d4.asciidoc @@ -0,0 +1,67 @@ +// mapping/runtime.asciidoc:687 + +[source, python] +---- +resp = client.bulk( + index="my-index-000001", + refresh=True, + body=[ + {"index": {}}, + { + "@timestamp": "2020-06-21T15:00:01-05:00", + "message": '211.11.9.0 - - [2020-06-21T15:00:01-05:00] "GET /english/index.html HTTP/1.0" 304 0', + }, + {"index": {}}, + { + "@timestamp": "2020-06-21T15:00:01-05:00", + "message": '211.11.9.0 - - [2020-06-21T15:00:01-05:00] "GET /english/index.html HTTP/1.0" 304 0', + }, + {"index": {}}, + { + "@timestamp": "2020-04-30T14:30:17-05:00", + "message": '40.135.0.0 - - [2020-04-30T14:30:17-05:00] "GET /images/hm_bg.jpg HTTP/1.0" 200 24736', + }, + {"index": {}}, + { + "@timestamp": "2020-04-30T14:30:53-05:00", + "message": '232.0.0.0 - - [2020-04-30T14:30:53-05:00] "GET /images/hm_bg.jpg HTTP/1.0" 200 24736', + }, + {"index": {}}, + { + "@timestamp": "2020-04-30T14:31:12-05:00", + "message": '26.1.0.0 - - [2020-04-30T14:31:12-05:00] "GET /images/hm_bg.jpg HTTP/1.0" 200 24736', + }, + {"index": {}}, + { + "@timestamp": "2020-04-30T14:31:19-05:00", + "message": '247.37.0.0 - - [2020-04-30T14:31:19-05:00] "GET /french/splash_inet.html HTTP/1.0" 200 3781', + }, + {"index": {}}, + { + "@timestamp": "2020-04-30T14:31:27-05:00", + "message": '252.0.0.0 - - [2020-04-30T14:31:27-05:00] "GET /images/hm_bg.jpg HTTP/1.0" 200 24736', + }, + {"index": {}}, + { + "@timestamp": "2020-04-30T14:31:29-05:00", + "message": '247.37.0.0 - - [2020-04-30T14:31:29-05:00] "GET /images/hm_brdl.gif HTTP/1.0" 304 0', + }, + {"index": {}}, + { + "@timestamp": "2020-04-30T14:31:29-05:00", + "message": '247.37.0.0 - - [2020-04-30T14:31:29-05:00] "GET /images/hm_arw.gif HTTP/1.0" 304 0', + }, + {"index": {}}, + { + "@timestamp": "2020-04-30T14:31:32-05:00", + "message": '247.37.0.0 - - [2020-04-30T14:31:32-05:00] "GET /images/nav_bg_top.gif HTTP/1.0" 200 929', + }, + {"index": {}}, + { + "@timestamp": "2020-04-30T14:31:43-05:00", + "message": '247.37.0.0 - - [2020-04-30T14:31:43-05:00] "GET /french/images/nav_venue_off.gif HTTP/1.0" 304 0', + }, + ], +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/8f9f88cf9a27c1138226efb94ac09e73.asciidoc b/docs/examples/8f9f88cf9a27c1138226efb94ac09e73.asciidoc new file mode 100644 index 000000000..a8bc49460 --- /dev/null +++ b/docs/examples/8f9f88cf9a27c1138226efb94ac09e73.asciidoc @@ -0,0 +1,10 @@ +// mapping/types/ip.asciidoc:112 + +[source, python] +---- +resp = client.search( + index="my-index-000001", + body={"query": {"term": {"ip_addr": "192.168.0.0/16"}}}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/909a032a9c1f7095b798444705b09ad6.asciidoc b/docs/examples/909a032a9c1f7095b798444705b09ad6.asciidoc new file mode 100644 index 000000000..05448d934 --- /dev/null +++ b/docs/examples/909a032a9c1f7095b798444705b09ad6.asciidoc @@ -0,0 +1,12 @@ +// mapping/types/geo-shape.asciidoc:444 + +[source, python] +---- +resp = client.index( + index="example", + body={ + "location": "GEOMETRYCOLLECTION (POINT (100.0 0.0), LINESTRING (101.0 0.0, 102.0 1.0))" + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/92284d24bbb80ce6943f2ddcbf74b833.asciidoc b/docs/examples/92284d24bbb80ce6943f2ddcbf74b833.asciidoc new file mode 100644 index 000000000..d4b83876a --- /dev/null +++ b/docs/examples/92284d24bbb80ce6943f2ddcbf74b833.asciidoc @@ -0,0 +1,28 @@ +// mapping/types/flattened.asciidoc:136 + +[source, python] +---- +resp = client.indices.create( + index="my-index-000001", + body={ + "mappings": { + "properties": {"flattened_field": {"type": "flattened"}} + } + }, +) +print(resp) + +resp = client.index( + index="my-index-000001", + id="1", + refresh="true", + body={"flattened_field": {"subfield": "value"}}, +) +print(resp) + +resp = client.search( + index="my-index-000001", + body={"fields": ["flattened_field.subfield"], "_source": False}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/92d0c12d53a900308150d572c3f2f82f.asciidoc b/docs/examples/92d0c12d53a900308150d572c3f2f82f.asciidoc new file mode 100644 index 000000000..d06bc4dbb --- /dev/null +++ b/docs/examples/92d0c12d53a900308150d572c3f2f82f.asciidoc @@ -0,0 +1,21 @@ +// mapping/dynamic/templates.asciidoc:477 + +[source, python] +---- +resp = client.indices.create( + index="my-index-000001", + body={ + "mappings": { + "dynamic_templates": [ + { + "strings_as_keywords": { + "match_mapping_type": "string", + "mapping": {"type": "keyword"}, + } + } + ] + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/92fa6608673cec5a2ed568a07e80d36b.asciidoc b/docs/examples/92fa6608673cec5a2ed568a07e80d36b.asciidoc new file mode 100644 index 000000000..ed121d8cc --- /dev/null +++ b/docs/examples/92fa6608673cec5a2ed568a07e80d36b.asciidoc @@ -0,0 +1,14 @@ +// mapping/runtime.asciidoc:1551 + +[source, python] +---- +resp = client.search( + index="my-index-000001", + body={ + "query": { + "range": {"timestamp": {"gte": "2020-04-30T14:31:27-05:00"}} + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/936d809c848f8b77d5b55f57f0aab89a.asciidoc b/docs/examples/936d809c848f8b77d5b55f57f0aab89a.asciidoc new file mode 100644 index 000000000..a8b4c5692 --- /dev/null +++ b/docs/examples/936d809c848f8b77d5b55f57f0aab89a.asciidoc @@ -0,0 +1,17 @@ +// mapping/dynamic/field-mapping.asciidoc:81 + +[source, python] +---- +resp = client.indices.create( + index="my-index-000001", + body={"mappings": {"date_detection": False}}, +) +print(resp) + +resp = client.index( + index="my-index-000001", + id="1", + body={"create_date": "2015/09/02"}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/937ffc65cbb20505a8aba25b37a796a5.asciidoc b/docs/examples/937ffc65cbb20505a8aba25b37a796a5.asciidoc new file mode 100644 index 000000000..f249969c8 --- /dev/null +++ b/docs/examples/937ffc65cbb20505a8aba25b37a796a5.asciidoc @@ -0,0 +1,26 @@ +// mapping/types/boolean.asciidoc:22 + +[source, python] +---- +resp = client.indices.create( + index="my-index-000001", + body={ + "mappings": {"properties": {"is_published": {"type": "boolean"}}} + }, +) +print(resp) + +resp = client.index( + index="my-index-000001", + id="1", + refresh=True, + body={"is_published": "true"}, +) +print(resp) + +resp = client.search( + index="my-index-000001", + body={"query": {"term": {"is_published": True}}}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/93bd651aff81daa2b86f9f2089e6d088.asciidoc b/docs/examples/93bd651aff81daa2b86f9f2089e6d088.asciidoc new file mode 100644 index 000000000..6b9c8259b --- /dev/null +++ b/docs/examples/93bd651aff81daa2b86f9f2089e6d088.asciidoc @@ -0,0 +1,28 @@ +// mapping/types/parent-join.asciidoc:49 + +[source, python] +---- +resp = client.index( + index="my-index-000001", + id="1", + refresh=True, + body={ + "my_id": "1", + "text": "This is a question", + "my_join_field": {"name": "question"}, + }, +) +print(resp) + +resp = client.index( + index="my-index-000001", + id="2", + refresh=True, + body={ + "my_id": "2", + "text": "This is another question", + "my_join_field": {"name": "question"}, + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/93d7ba4130722cae04f9690e52a8f54f.asciidoc b/docs/examples/93d7ba4130722cae04f9690e52a8f54f.asciidoc new file mode 100644 index 000000000..394e79b58 --- /dev/null +++ b/docs/examples/93d7ba4130722cae04f9690e52a8f54f.asciidoc @@ -0,0 +1,15 @@ +// mapping/types/geo-shape.asciidoc:460 + +[source, python] +---- +resp = client.index( + index="example", + body={ + "location": { + "type": "envelope", + "coordinates": [[100, 1], [101, 0]], + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/944a2dc22dae2a8503299926326a9c18.asciidoc b/docs/examples/944a2dc22dae2a8503299926326a9c18.asciidoc new file mode 100644 index 000000000..59f9a7d17 --- /dev/null +++ b/docs/examples/944a2dc22dae2a8503299926326a9c18.asciidoc @@ -0,0 +1,23 @@ +// mapping/types/ip.asciidoc:11 + +[source, python] +---- +resp = client.indices.create( + index="my-index-000001", + body={"mappings": {"properties": {"ip_addr": {"type": "ip"}}}}, +) +print(resp) + +resp = client.index( + index="my-index-000001", + id="1", + body={"ip_addr": "192.168.1.1"}, +) +print(resp) + +resp = client.search( + index="my-index-000001", + body={"query": {"term": {"ip_addr": "192.168.0.0/16"}}}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/96e137e42d12c180e2c702db30714a9e.asciidoc b/docs/examples/96e137e42d12c180e2c702db30714a9e.asciidoc new file mode 100644 index 000000000..683ab3f8b --- /dev/null +++ b/docs/examples/96e137e42d12c180e2c702db30714a9e.asciidoc @@ -0,0 +1,10 @@ +// mapping/types/text.asciidoc:39 + +[source, python] +---- +resp = client.indices.create( + index="my-index-000001", + body={"mappings": {"properties": {"full_name": {"type": "text"}}}}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/97f260817b60f3deb7f7034d7dee7e12.asciidoc b/docs/examples/97f260817b60f3deb7f7034d7dee7e12.asciidoc new file mode 100644 index 000000000..5ba883ba4 --- /dev/null +++ b/docs/examples/97f260817b60f3deb7f7034d7dee7e12.asciidoc @@ -0,0 +1,35 @@ +// mapping/types/aggregate-metric-double.asciidoc:267 + +[source, python] +---- +resp = client.indices.create( + index="idx", + body={ + "mappings": { + "_source": {"mode": "synthetic"}, + "properties": { + "agg_metric": { + "type": "aggregate_metric_double", + "metrics": ["min", "max", "sum", "value_count"], + "default_metric": "max", + } + }, + } + }, +) +print(resp) + +resp = client.index( + index="idx", + id="1", + body={ + "agg_metric": { + "min": -302.5, + "max": 702.3, + "sum": 200, + "value_count": 25, + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/9e0e3ce27967f164f4585c5231ba9c75.asciidoc b/docs/examples/9e0e3ce27967f164f4585c5231ba9c75.asciidoc new file mode 100644 index 000000000..9f44357b0 --- /dev/null +++ b/docs/examples/9e0e3ce27967f164f4585c5231ba9c75.asciidoc @@ -0,0 +1,12 @@ +// mapping/types/search-as-you-type.asciidoc:71 + +[source, python] +---- +resp = client.index( + index="my-index-000001", + id="1", + refresh=True, + body={"my_field": "quick brown fox jump lazy dog"}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/a04a8d90f8245ff5f30a9983909faa1d.asciidoc b/docs/examples/a04a8d90f8245ff5f30a9983909faa1d.asciidoc new file mode 100644 index 000000000..dcdbb8973 --- /dev/null +++ b/docs/examples/a04a8d90f8245ff5f30a9983909faa1d.asciidoc @@ -0,0 +1,44 @@ +// mapping/types/percolator.asciidoc:427 + +[source, python] +---- +resp = client.indices.create( + index="my_queries1", + body={ + "settings": { + "analysis": { + "analyzer": { + "wildcard_prefix": { + "type": "custom", + "tokenizer": "standard", + "filter": ["lowercase", "wildcard_edge_ngram"], + } + }, + "filter": { + "wildcard_edge_ngram": { + "type": "edge_ngram", + "min_gram": 1, + "max_gram": 32, + } + }, + } + }, + "mappings": { + "properties": { + "query": {"type": "percolator"}, + "my_field": { + "type": "text", + "fields": { + "prefix": { + "type": "text", + "analyzer": "wildcard_prefix", + "search_analyzer": "standard", + } + }, + }, + } + }, + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/a2dabdcbb661e7690166ae6d0de27e46.asciidoc b/docs/examples/a2dabdcbb661e7690166ae6d0de27e46.asciidoc new file mode 100644 index 000000000..0651bff53 --- /dev/null +++ b/docs/examples/a2dabdcbb661e7690166ae6d0de27e46.asciidoc @@ -0,0 +1,10 @@ +// mapping/types/alias.asciidoc:55 + +[source, python] +---- +resp = client.field_caps( + index="trips", + fields=["route_*", "transit_mode"], +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/a45d80a3fdba70c1b1ba493e51652c8a.asciidoc b/docs/examples/a45d80a3fdba70c1b1ba493e51652c8a.asciidoc new file mode 100644 index 000000000..681a9f425 --- /dev/null +++ b/docs/examples/a45d80a3fdba70c1b1ba493e51652c8a.asciidoc @@ -0,0 +1,15 @@ +// mapping/types/shape.asciidoc:284 + +[source, python] +---- +resp = client.index( + index="example", + body={ + "location": { + "type": "multipoint", + "coordinates": [[1002, 1002], [1003, 2000]], + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/a73a9a6f19516b8ead63182a9ae5b540.asciidoc b/docs/examples/a73a9a6f19516b8ead63182a9ae5b540.asciidoc new file mode 100644 index 000000000..1415d97c3 --- /dev/null +++ b/docs/examples/a73a9a6f19516b8ead63182a9ae5b540.asciidoc @@ -0,0 +1,12 @@ +// mapping/types/shape.asciidoc:330 + +[source, python] +---- +resp = client.index( + index="example", + body={ + "location": "MULTILINESTRING ((1002.0 200.0, 1003.0 200.0, 1003.0 300.0, 1002.0 300.0), (1000.0 100.0, 1001.0 100.0, 1001.0 100.0, 1000.0 100.0), (1000.2 0.2, 1000.8 100.2, 1000.8 100.8, 1000.2 100.8))" + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/a7e58d4dc477a84c1306fd5749aafd8b.asciidoc b/docs/examples/a7e58d4dc477a84c1306fd5749aafd8b.asciidoc new file mode 100644 index 000000000..338c48280 --- /dev/null +++ b/docs/examples/a7e58d4dc477a84c1306fd5749aafd8b.asciidoc @@ -0,0 +1,18 @@ +// mapping/explicit-mapping.asciidoc:20 + +[source, python] +---- +resp = client.indices.create( + index="my-index-000001", + body={ + "mappings": { + "properties": { + "age": {"type": "integer"}, + "email": {"type": "keyword"}, + "name": {"type": "text"}, + } + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/a89052bcdfe40e604a98d12be6ae59d2.asciidoc b/docs/examples/a89052bcdfe40e604a98d12be6ae59d2.asciidoc new file mode 100644 index 000000000..dee213fac --- /dev/null +++ b/docs/examples/a89052bcdfe40e604a98d12be6ae59d2.asciidoc @@ -0,0 +1,10 @@ +// mapping/types/geo-shape.asciidoc:475 + +[source, python] +---- +resp = client.index( + index="example", + body={"location": "BBOX (100.0, 102.0, 2.0, 0.0)"}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/a9280b55a7284952f604ec7bece712f6.asciidoc b/docs/examples/a9280b55a7284952f604ec7bece712f6.asciidoc new file mode 100644 index 000000000..ab020b7c2 --- /dev/null +++ b/docs/examples/a9280b55a7284952f604ec7bece712f6.asciidoc @@ -0,0 +1,17 @@ +// mapping/runtime.asciidoc:1188 + +[source, python] +---- +resp = client.search( + index="my-index-000001", + body={ + "query": { + "range": { + "voltage_corrected": {"gte": 16, "lte": 20, "boost": 1} + } + }, + "fields": ["voltage_corrected", "node"], + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/a97f984c01fa1d96e6d33a0e8e2cb90f.asciidoc b/docs/examples/a97f984c01fa1d96e6d33a0e8e2cb90f.asciidoc new file mode 100644 index 000000000..d39fc69f9 --- /dev/null +++ b/docs/examples/a97f984c01fa1d96e6d33a0e8e2cb90f.asciidoc @@ -0,0 +1,17 @@ +// mapping/types/percolator.asciidoc:20 + +[source, python] +---- +resp = client.indices.create( + index="my-index-000001", + body={ + "mappings": { + "properties": { + "query": {"type": "percolator"}, + "field": {"type": "text"}, + } + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/ab1a989958c1d345a9dc3dd36ad90c27.asciidoc b/docs/examples/ab1a989958c1d345a9dc3dd36ad90c27.asciidoc new file mode 100644 index 000000000..1bb625fe2 --- /dev/null +++ b/docs/examples/ab1a989958c1d345a9dc3dd36ad90c27.asciidoc @@ -0,0 +1,12 @@ +// mapping/types/shape.asciidoc:242 + +[source, python] +---- +resp = client.index( + index="example", + body={ + "location": "POLYGON ((1000.0 1000.0, 1001.0 1000.0, 1001.0 1001.0, 1000.0 1001.0, 1000.0 1000.0), (1000.2 1000.2, 1000.8 1000.2, 1000.8 1000.8, 1000.2 1000.8, 1000.2 1000.2))" + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/ac483996d479946d57c374c3a86b2621.asciidoc b/docs/examples/ac483996d479946d57c374c3a86b2621.asciidoc new file mode 100644 index 000000000..83da2415c --- /dev/null +++ b/docs/examples/ac483996d479946d57c374c3a86b2621.asciidoc @@ -0,0 +1,14 @@ +// mapping/types/search-as-you-type.asciidoc:18 + +[source, python] +---- +resp = client.indices.create( + index="my-index-000001", + body={ + "mappings": { + "properties": {"my_field": {"type": "search_as_you_type"}} + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/ad57ccba0a060da4f5313692fa26a235.asciidoc b/docs/examples/ad57ccba0a060da4f5313692fa26a235.asciidoc new file mode 100644 index 000000000..ce87ee16d --- /dev/null +++ b/docs/examples/ad57ccba0a060da4f5313692fa26a235.asciidoc @@ -0,0 +1,42 @@ +// mapping/types/date_nanos.asciidoc:30 + +[source, python] +---- +resp = client.indices.create( + index="my-index-000001", + body={"mappings": {"properties": {"date": {"type": "date_nanos"}}}}, +) +print(resp) + +resp = client.bulk( + index="my-index-000001", + refresh=True, + body=[ + {"index": {"_id": "1"}}, + {"date": "2015-01-01"}, + {"index": {"_id": "2"}}, + {"date": "2015-01-01T12:10:30.123456789Z"}, + {"index": {"_id": "3"}}, + {"date": 1420070400000}, + ], +) +print(resp) + +resp = client.search( + index="my-index-000001", + body={ + "sort": {"date": "asc"}, + "runtime_mappings": { + "date_has_nanos": { + "type": "boolean", + "script": "emit(doc['date'].value.nano != 0)", + } + }, + "fields": [ + {"field": "date", "format": "strict_date_optional_time_nanos"}, + {"field": "date_has_nanos"}, + ], + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/ae398a6b6494e7982ef2549fc2cd2d8e.asciidoc b/docs/examples/ae398a6b6494e7982ef2549fc2cd2d8e.asciidoc new file mode 100644 index 000000000..c98de5ff8 --- /dev/null +++ b/docs/examples/ae398a6b6494e7982ef2549fc2cd2d8e.asciidoc @@ -0,0 +1,45 @@ +// mapping/dynamic/templates.asciidoc:353 + +[source, python] +---- +resp = client.indices.create( + index="my-index-000001", + body={ + "mappings": { + "dynamic_templates": [ + { + "full_name": { + "path_match": ["name.*", "user.name.*"], + "path_unmatch": ["*.middle", "*.midinitial"], + "mapping": { + "type": "text", + "copy_to": "full_name", + }, + } + } + ] + } + }, +) +print(resp) + +resp = client.index( + index="my-index-000001", + id="1", + body={ + "name": {"first": "John", "middle": "Winston", "last": "Lennon"} + }, +) +print(resp) + +resp = client.index( + index="my-index-000001", + id="2", + body={ + "user": { + "name": {"first": "Jane", "midinitial": "M", "last": "Salazar"} + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/afef5cac988592b97ae289ab39c2f437.asciidoc b/docs/examples/afef5cac988592b97ae289ab39c2f437.asciidoc new file mode 100644 index 000000000..206d014aa --- /dev/null +++ b/docs/examples/afef5cac988592b97ae289ab39c2f437.asciidoc @@ -0,0 +1,19 @@ +// mapping/types/text.asciidoc:292 + +[source, python] +---- +resp = client.indices.create( + index="my-index-000001", + body={ + "mappings": { + "properties": { + "my_field": { + "type": "text", + "fields": {"keyword": {"type": "keyword"}}, + } + } + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/b195068563b1dc0f721f5f8c8d172312.asciidoc b/docs/examples/b195068563b1dc0f721f5f8c8d172312.asciidoc new file mode 100644 index 000000000..44f78bcc7 --- /dev/null +++ b/docs/examples/b195068563b1dc0f721f5f8c8d172312.asciidoc @@ -0,0 +1,10 @@ +// mapping/types/shape.asciidoc:299 + +[source, python] +---- +resp = client.index( + index="example", + body={"location": "MULTIPOINT (1002.0 2000.0, 1003.0 2000.0)"}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/b3fffd96fdb118cd059b5f1d67d928de.asciidoc b/docs/examples/b3fffd96fdb118cd059b5f1d67d928de.asciidoc new file mode 100644 index 000000000..171f1277f --- /dev/null +++ b/docs/examples/b3fffd96fdb118cd059b5f1d67d928de.asciidoc @@ -0,0 +1,15 @@ +// mapping/types/geo-shape.asciidoc:331 + +[source, python] +---- +resp = client.index( + index="example", + body={ + "location": { + "type": "MultiPoint", + "coordinates": [[102, 2], [103, 2]], + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/b430122345d560bbd2a77826f5c475f7.asciidoc b/docs/examples/b430122345d560bbd2a77826f5c475f7.asciidoc new file mode 100644 index 000000000..436ff6bdb --- /dev/null +++ b/docs/examples/b430122345d560bbd2a77826f5c475f7.asciidoc @@ -0,0 +1,34 @@ +// mapping/dynamic/templates.asciidoc:272 + +[source, python] +---- +resp = client.indices.create( + index="my-index-000001", + body={ + "mappings": { + "dynamic_templates": [ + { + "ip_fields": { + "match": ["ip_*", "*_ip"], + "unmatch": ["one*", "*two"], + "mapping": {"type": "ip"}, + } + } + ] + } + }, +) +print(resp) + +resp = client.index( + index="my-index", + id="1", + body={ + "one_ip": "will not match", + "ip_two": "will not match", + "three_ip": "12.12.12.12", + "ip_four": "13.13.13.13", + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/b4f3165e873f551fbaa03945877eb370.asciidoc b/docs/examples/b4f3165e873f551fbaa03945877eb370.asciidoc new file mode 100644 index 000000000..f34dbe7dc --- /dev/null +++ b/docs/examples/b4f3165e873f551fbaa03945877eb370.asciidoc @@ -0,0 +1,17 @@ +// mapping/dynamic/field-mapping.asciidoc:126 + +[source, python] +---- +resp = client.indices.create( + index="my-index-000001", + body={"mappings": {"dynamic_date_formats": ["yyyy/MM", "MM/dd/yyyy"]}}, +) +print(resp) + +resp = client.index( + index="my-index-000001", + id="1", + body={"create_date": "09/25/2015"}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/b504119238b44cddd3b5944da20a498d.asciidoc b/docs/examples/b504119238b44cddd3b5944da20a498d.asciidoc new file mode 100644 index 000000000..1896c8b7e --- /dev/null +++ b/docs/examples/b504119238b44cddd3b5944da20a498d.asciidoc @@ -0,0 +1,12 @@ +// mapping/types/shape.asciidoc:214 + +[source, python] +---- +resp = client.index( + index="example", + body={ + "location": "POLYGON ((1000.0 -1001.0, 1001.0 -1001.0, 1001.0 -1000.0, 1000.0 -1000.0, 1000.0 -1001.0))" + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/ba5dc6fb9bbe1406714da5d641462a23.asciidoc b/docs/examples/ba5dc6fb9bbe1406714da5d641462a23.asciidoc new file mode 100644 index 000000000..b162caf00 --- /dev/null +++ b/docs/examples/ba5dc6fb9bbe1406714da5d641462a23.asciidoc @@ -0,0 +1,22 @@ +// mapping/dynamic/templates.asciidoc:96 + +[source, python] +---- +resp = client.indices.create( + index="my-index-000001", + body={ + "mappings": { + "dynamic_templates": [ + { + "strings_as_ip": { + "match_mapping_type": "string", + "match": "ip*", + "runtime": {"type": "ip"}, + } + } + ] + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/bb975b342de7e838ebf6a36aaa1a8749.asciidoc b/docs/examples/bb975b342de7e838ebf6a36aaa1a8749.asciidoc new file mode 100644 index 000000000..3426d6fb8 --- /dev/null +++ b/docs/examples/bb975b342de7e838ebf6a36aaa1a8749.asciidoc @@ -0,0 +1,16 @@ +// mapping/types/parent-join.asciidoc:477 + +[source, python] +---- +resp = client.index( + index="my-index-000001", + id="3", + routing="1", + refresh=True, + body={ + "text": "This is a vote", + "my_join_field": {"name": "vote", "parent": "2"}, + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/bd7330af2609bdd8aa10958f5e640b93.asciidoc b/docs/examples/bd7330af2609bdd8aa10958f5e640b93.asciidoc new file mode 100644 index 000000000..694070642 --- /dev/null +++ b/docs/examples/bd7330af2609bdd8aa10958f5e640b93.asciidoc @@ -0,0 +1,12 @@ +// mapping/types/percolator.asciidoc:649 + +[source, python] +---- +resp = client.index( + index="my_queries2", + id="2", + refresh=True, + body={"query": {"match": {"my_field.suffix": "xyz"}}}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/be9836fe55c5fada404a2adc1663d832.asciidoc b/docs/examples/be9836fe55c5fada404a2adc1663d832.asciidoc new file mode 100644 index 000000000..308fff79c --- /dev/null +++ b/docs/examples/be9836fe55c5fada404a2adc1663d832.asciidoc @@ -0,0 +1,22 @@ +// mapping/runtime.asciidoc:1437 + +[source, python] +---- +resp = client.indices.put_mapping( + index="my-index-000001", + body={ + "runtime": { + "http": { + "type": "composite", + "script": 'emit(grok("%{COMMONAPACHELOG}").extract(doc["message"].value))', + "fields": { + "clientip": {"type": "ip"}, + "verb": {"type": "keyword"}, + "response": {"type": "long"}, + }, + } + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/bed14cc152522ca0726ac3746ebc31db.asciidoc b/docs/examples/bed14cc152522ca0726ac3746ebc31db.asciidoc new file mode 100644 index 000000000..4fc8297e0 --- /dev/null +++ b/docs/examples/bed14cc152522ca0726ac3746ebc31db.asciidoc @@ -0,0 +1,20 @@ +// mapping/types/unsigned_long.asciidoc:31 + +[source, python] +---- +resp = client.bulk( + index="my_index", + refresh=True, + body=[ + {"index": {"_id": 1}}, + {"my_counter": 0}, + {"index": {"_id": 2}}, + {"my_counter": 9223372036854776000}, + {"index": {"_id": 3}}, + {"my_counter": 18446744073709552000}, + {"index": {"_id": 4}}, + {"my_counter": 18446744073709552000}, + ], +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/c012f42b26eb8dd9b197644c3ed954cf.asciidoc b/docs/examples/c012f42b26eb8dd9b197644c3ed954cf.asciidoc new file mode 100644 index 000000000..5fecd1065 --- /dev/null +++ b/docs/examples/c012f42b26eb8dd9b197644c3ed954cf.asciidoc @@ -0,0 +1,17 @@ +// mapping/dynamic/templates.asciidoc:400 + +[source, python] +---- +resp = client.index( + index="my-index-000001", + id="2", + body={ + "name": { + "first": "Paul", + "last": "McCartney", + "title": {"value": "Sir", "category": "order of chivalry"}, + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/c03ce952de42eae4b522cedc9fd3d14a.asciidoc b/docs/examples/c03ce952de42eae4b522cedc9fd3d14a.asciidoc new file mode 100644 index 000000000..24e58d7a7 --- /dev/null +++ b/docs/examples/c03ce952de42eae4b522cedc9fd3d14a.asciidoc @@ -0,0 +1,12 @@ +// mapping/types/geo-shape.asciidoc:270 + +[source, python] +---- +resp = client.index( + index="example", + body={ + "location": "POLYGON ((100.0 0.0, 101.0 0.0, 101.0 1.0, 100.0 1.0, 100.0 0.0), (100.2 0.2, 100.8 0.2, 100.8 0.8, 100.2 0.8, 100.2 0.2))" + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/c1bb395546102279296534522061829f.asciidoc b/docs/examples/c1bb395546102279296534522061829f.asciidoc new file mode 100644 index 000000000..8eb2678b8 --- /dev/null +++ b/docs/examples/c1bb395546102279296534522061829f.asciidoc @@ -0,0 +1,22 @@ +// mapping/types/geo-point.asciidoc:230 + +[source, python] +---- +resp = client.indices.create( + index="idx", + body={ + "mappings": { + "_source": {"mode": "synthetic"}, + "properties": {"point": {"type": "geo_point"}}, + } + }, +) +print(resp) + +resp = client.index( + index="idx", + id="1", + body={"point": [{"lat": -90, "lon": -80}, {"lat": 10, "lon": 30}]}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/c208de54369379e8d78ab201be18b6be.asciidoc b/docs/examples/c208de54369379e8d78ab201be18b6be.asciidoc new file mode 100644 index 000000000..87557d76b --- /dev/null +++ b/docs/examples/c208de54369379e8d78ab201be18b6be.asciidoc @@ -0,0 +1,30 @@ +// mapping/dynamic/templates.asciidoc:234 + +[source, python] +---- +resp = client.indices.create( + index="my-index-000001", + body={ + "mappings": { + "dynamic_templates": [ + { + "longs_as_strings": { + "match_mapping_type": "string", + "match": "long_*", + "unmatch": "*_text", + "mapping": {"type": "long"}, + } + } + ] + } + }, +) +print(resp) + +resp = client.index( + index="my-index-000001", + id="1", + body={"long_num": "5", "long_text": "foo"}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/c38c882c642dd412e8fa4c3eed49d12f.asciidoc b/docs/examples/c38c882c642dd412e8fa4c3eed49d12f.asciidoc new file mode 100644 index 000000000..5c4f35df8 --- /dev/null +++ b/docs/examples/c38c882c642dd412e8fa4c3eed49d12f.asciidoc @@ -0,0 +1,10 @@ +// mapping/types/search-as-you-type.asciidoc:147 + +[source, python] +---- +resp = client.search( + index="my-index-000001", + body={"query": {"match_phrase_prefix": {"my_field": "brown f"}}}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/c48b8bcd6f41e0d12b58e854e09ea893.asciidoc b/docs/examples/c48b8bcd6f41e0d12b58e854e09ea893.asciidoc new file mode 100644 index 000000000..fceda6c20 --- /dev/null +++ b/docs/examples/c48b8bcd6f41e0d12b58e854e09ea893.asciidoc @@ -0,0 +1,12 @@ +// mapping/types/shape.asciidoc:361 + +[source, python] +---- +resp = client.index( + index="example", + body={ + "location": "MULTIPOLYGON (((1002.0 200.0, 1003.0 200.0, 1003.0 300.0, 1002.0 300.0, 102.0 200.0)), ((1000.0 100.0, 1001.0 100.0, 1001.0 100.0, 1000.0 100.0, 1000.0 100.0), (1000.2 100.2, 1000.8 100.2, 1000.8 100.8, 1000.2 100.8, 1000.2 100.2)))" + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/c6151a0788a10a7f40da684d72c3255c.asciidoc b/docs/examples/c6151a0788a10a7f40da684d72c3255c.asciidoc new file mode 100644 index 000000000..a6c8846fa --- /dev/null +++ b/docs/examples/c6151a0788a10a7f40da684d72c3255c.asciidoc @@ -0,0 +1,39 @@ +// mapping/types/flattened.asciidoc:225 + +[source, python] +---- +resp = client.bulk( + index="my-index-000001", + refresh=True, + body=[ + {"index": {}}, + { + "title": "Something really urgent", + "labels": { + "priority": "urgent", + "release": ["v1.2.5", "v1.3.0"], + "timestamp": {"created": 1541458026, "closed": 1541457010}, + }, + }, + {"index": {}}, + { + "title": "Somewhat less urgent", + "labels": { + "priority": "high", + "release": ["v1.3.0"], + "timestamp": {"created": 1541458026, "closed": 1541457010}, + }, + }, + {"index": {}}, + { + "title": "Not urgent", + "labels": { + "priority": "low", + "release": ["v1.2.0"], + "timestamp": {"created": 1541458026, "closed": 1541457010}, + }, + }, + ], +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/c654b09be981be12fc7be0ba33f8652b.asciidoc b/docs/examples/c654b09be981be12fc7be0ba33f8652b.asciidoc new file mode 100644 index 000000000..1f96f2840 --- /dev/null +++ b/docs/examples/c654b09be981be12fc7be0ba33f8652b.asciidoc @@ -0,0 +1,24 @@ +// mapping/types/shape.asciidoc:313 + +[source, python] +---- +resp = client.index( + index="example", + body={ + "location": { + "type": "multilinestring", + "coordinates": [ + [[1002, 200], [1003, 200], [1003, 300], [1002, 300]], + [[1000, 100], [1001, 100], [1001, 100], [1000, 100]], + [ + [1000.2, 100.2], + [1000.8, 100.2], + [1000.8, 100.8], + [1000.2, 100.8], + ], + ], + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/c725c72ead2dae0205a5a34a50d7ad83.asciidoc b/docs/examples/c725c72ead2dae0205a5a34a50d7ad83.asciidoc new file mode 100644 index 000000000..12dbc9f99 --- /dev/null +++ b/docs/examples/c725c72ead2dae0205a5a34a50d7ad83.asciidoc @@ -0,0 +1,52 @@ +// mapping/types/rank-features.asciidoc:16 + +[source, python] +---- +resp = client.indices.create( + index="my-index-000001", + body={ + "mappings": { + "properties": { + "topics": {"type": "rank_features"}, + "negative_reviews": { + "type": "rank_features", + "positive_score_impact": False, + }, + } + } + }, +) +print(resp) + +resp = client.index( + index="my-index-000001", + id="1", + body={ + "topics": {"politics": 20, "economics": 50.8}, + "negative_reviews": {"1star": 10, "2star": 100}, + }, +) +print(resp) + +resp = client.index( + index="my-index-000001", + id="2", + body={ + "topics": {"politics": 5.2, "sports": 80.1}, + "negative_reviews": {"1star": 1, "2star": 10}, + }, +) +print(resp) + +resp = client.search( + index="my-index-000001", + body={"query": {"rank_feature": {"field": "topics.politics"}}}, +) +print(resp) + +resp = client.search( + index="my-index-000001", + body={"query": {"rank_feature": {"field": "negative_reviews.1star"}}}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/cb71c6ecfb8b19725c374572444e5d32.asciidoc b/docs/examples/cb71c6ecfb8b19725c374572444e5d32.asciidoc new file mode 100644 index 000000000..d835a6603 --- /dev/null +++ b/docs/examples/cb71c6ecfb8b19725c374572444e5d32.asciidoc @@ -0,0 +1,15 @@ +// mapping/runtime.asciidoc:366 + +[source, python] +---- +resp = client.search( + index="my-index-000001", + body={ + "aggs": { + "avg_start": {"avg": {"field": "measures.start"}}, + "avg_end": {"avg": {"field": "measures.end"}}, + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/cc28a3dafcd5056f2a3ec07f6fda5091.asciidoc b/docs/examples/cc28a3dafcd5056f2a3ec07f6fda5091.asciidoc new file mode 100644 index 000000000..59a62f1b6 --- /dev/null +++ b/docs/examples/cc28a3dafcd5056f2a3ec07f6fda5091.asciidoc @@ -0,0 +1,20 @@ +// mapping/runtime.asciidoc:287 + +[source, python] +---- +resp = client.search( + index="my-index-000001", + body={ + "runtime_mappings": { + "day_of_week": { + "type": "keyword", + "script": { + "source": "emit(doc['@timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT))" + }, + } + }, + "aggs": {"day_of_week": {"terms": {"field": "day_of_week"}}}, + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/cdc04e6d3d37f036c7045ee4a582ef06.asciidoc b/docs/examples/cdc04e6d3d37f036c7045ee4a582ef06.asciidoc new file mode 100644 index 000000000..b2842633a --- /dev/null +++ b/docs/examples/cdc04e6d3d37f036c7045ee4a582ef06.asciidoc @@ -0,0 +1,30 @@ +// mapping/dynamic/templates.asciidoc:610 + +[source, python] +---- +resp = client.indices.create( + index="my-index-000001", + body={ + "mappings": { + "dynamic_templates": [ + { + "strings_as_keywords": { + "match_mapping_type": "string", + "mapping": { + "type": "text", + "norms": False, + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 256, + } + }, + }, + } + } + ] + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/d1ecce3632ae338b5e329b0e5ff3bed7.asciidoc b/docs/examples/d1ecce3632ae338b5e329b0e5ff3bed7.asciidoc new file mode 100644 index 000000000..df90393ec --- /dev/null +++ b/docs/examples/d1ecce3632ae338b5e329b0e5ff3bed7.asciidoc @@ -0,0 +1,20 @@ +// mapping/types/parent-join.asciidoc:382 + +[source, python] +---- +resp = client.indices.create( + index="my-index-000001", + body={ + "mappings": { + "properties": { + "my_join_field": { + "type": "join", + "relations": {"question": "answer"}, + "eager_global_ordinals": False, + } + } + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/d2f6040c058a9555dfa62bb42d896a8f.asciidoc b/docs/examples/d2f6040c058a9555dfa62bb42d896a8f.asciidoc new file mode 100644 index 000000000..f80b945aa --- /dev/null +++ b/docs/examples/d2f6040c058a9555dfa62bb42d896a8f.asciidoc @@ -0,0 +1,17 @@ +// mapping/types/percolator.asciidoc:513 + +[source, python] +---- +resp = client.search( + index="my_queries1", + body={ + "query": { + "percolate": { + "field": "query", + "document": {"my_field": "abcd"}, + } + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/d3a5b70d493e0bd77b3f2b586341c83c.asciidoc b/docs/examples/d3a5b70d493e0bd77b3f2b586341c83c.asciidoc new file mode 100644 index 000000000..96e81aedf --- /dev/null +++ b/docs/examples/d3a5b70d493e0bd77b3f2b586341c83c.asciidoc @@ -0,0 +1,17 @@ +// mapping/runtime.asciidoc:1637 + +[source, python] +---- +resp = client.indices.put_mapping( + index="my-index-000001", + body={ + "runtime": { + "http.responses": { + "type": "long", + "script": '\n String response=dissect(\'%{clientip} %{ident} %{auth} [%{@timestamp}] "%{verb} %{request} HTTP/%{httpversion}" %{response} %{size}\').extract(doc["message"].value)?.response;\n if (response != null) emit(Integer.parseInt(response));\n ', + } + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/d5abaf1fd26f0abf410dd8827d077bbf.asciidoc b/docs/examples/d5abaf1fd26f0abf410dd8827d077bbf.asciidoc new file mode 100644 index 000000000..4ae35140e --- /dev/null +++ b/docs/examples/d5abaf1fd26f0abf410dd8827d077bbf.asciidoc @@ -0,0 +1,10 @@ +// mapping/types/parent-join.asciidoc:173 + +[source, python] +---- +resp = client.search( + index="my-index-000001", + body={"query": {"match_all": {}}, "sort": ["my_id"]}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/d64679f8a53928fe9958dbe5ee5d9d13.asciidoc b/docs/examples/d64679f8a53928fe9958dbe5ee5d9d13.asciidoc new file mode 100644 index 000000000..da13a71fc --- /dev/null +++ b/docs/examples/d64679f8a53928fe9958dbe5ee5d9d13.asciidoc @@ -0,0 +1,24 @@ +// mapping/types/parent-join.asciidoc:280 + +[source, python] +---- +resp = client.search( + index="my-index-000001", + body={ + "query": {"parent_id": {"type": "answer", "id": "1"}}, + "aggs": { + "parents": { + "terms": {"field": "my_join_field#question", "size": 10} + } + }, + "runtime_mappings": { + "parent": { + "type": "long", + "script": "\n emit(Integer.parseInt(doc['my_join_field#question'].value)) \n ", + } + }, + "fields": [{"field": "parent"}], + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/d7919fb6f4d02dde1390775eb8365b79.asciidoc b/docs/examples/d7919fb6f4d02dde1390775eb8365b79.asciidoc new file mode 100644 index 000000000..78b48566d --- /dev/null +++ b/docs/examples/d7919fb6f4d02dde1390775eb8365b79.asciidoc @@ -0,0 +1,10 @@ +// mapping/types/text.asciidoc:320 + +[source, python] +---- +resp = client.indices.put_mapping( + index="my-index-000001", + body={"properties": {"my_field": {"type": "text", "fielddata": True}}}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/d98fb2ff2cdd154dff4a576430755d98.asciidoc b/docs/examples/d98fb2ff2cdd154dff4a576430755d98.asciidoc new file mode 100644 index 000000000..1742a248c --- /dev/null +++ b/docs/examples/d98fb2ff2cdd154dff4a576430755d98.asciidoc @@ -0,0 +1,27 @@ +// mapping/runtime.asciidoc:1124 + +[source, python] +---- +resp = client.indices.create( + index="my-index-000001", + body={ + "mappings": { + "properties": { + "timestamp": {"type": "date"}, + "temperature": {"type": "long"}, + "voltage": {"type": "double"}, + "node": {"type": "keyword"}, + "voltage_corrected": { + "type": "double", + "on_script_error": "fail", + "script": { + "source": "\n emit(doc['voltage'].value * params['multiplier'])\n ", + "params": {"multiplier": 4}, + }, + }, + } + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/d9a1ad1c5746b75972c74dd4d3a3d623.asciidoc b/docs/examples/d9a1ad1c5746b75972c74dd4d3a3d623.asciidoc new file mode 100644 index 000000000..190860fcc --- /dev/null +++ b/docs/examples/d9a1ad1c5746b75972c74dd4d3a3d623.asciidoc @@ -0,0 +1,22 @@ +// mapping/types/parent-join.asciidoc:442 + +[source, python] +---- +resp = client.indices.create( + index="my-index-000001", + body={ + "mappings": { + "properties": { + "my_join_field": { + "type": "join", + "relations": { + "question": ["answer", "comment"], + "answer": "vote", + }, + } + } + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/dabb159e0b3456024889fb9754a10655.asciidoc b/docs/examples/dabb159e0b3456024889fb9754a10655.asciidoc new file mode 100644 index 000000000..b0f2fa8e7 --- /dev/null +++ b/docs/examples/dabb159e0b3456024889fb9754a10655.asciidoc @@ -0,0 +1,10 @@ +// mapping/types/shape.asciidoc:76 + +[source, python] +---- +resp = client.indices.create( + index="example", + body={"mappings": {"properties": {"geometry": {"type": "shape"}}}}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/dabcf0bead37cae1d3e5d2813fd3ccfe.asciidoc b/docs/examples/dabcf0bead37cae1d3e5d2813fd3ccfe.asciidoc new file mode 100644 index 000000000..778338f40 --- /dev/null +++ b/docs/examples/dabcf0bead37cae1d3e5d2813fd3ccfe.asciidoc @@ -0,0 +1,10 @@ +// mapping/types/ip.asciidoc:143 + +[source, python] +---- +resp = client.search( + index="my-index-000001", + body={"query": {"query_string": {"query": 'ip_addr:"2001:db8::/48"'}}}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/dcee24dba43050e4b01b6e3a3211ce09.asciidoc b/docs/examples/dcee24dba43050e4b01b6e3a3211ce09.asciidoc new file mode 100644 index 000000000..0f01fe413 --- /dev/null +++ b/docs/examples/dcee24dba43050e4b01b6e3a3211ce09.asciidoc @@ -0,0 +1,20 @@ +// mapping/runtime.asciidoc:1283 + +[source, python] +---- +resp = client.indices.create( + index="my-index-000001", + body={ + "mappings": { + "properties": { + "@timestamp": { + "format": "strict_date_optional_time||epoch_second", + "type": "date", + }, + "message": {"type": "wildcard"}, + } + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/dd792bb53703a57f9207e36d16e26255.asciidoc b/docs/examples/dd792bb53703a57f9207e36d16e26255.asciidoc new file mode 100644 index 000000000..cae554f0a --- /dev/null +++ b/docs/examples/dd792bb53703a57f9207e36d16e26255.asciidoc @@ -0,0 +1,54 @@ +// mapping/runtime.asciidoc:1164 + +[source, python] +---- +resp = client.bulk( + index="my-index-000001", + refresh="true", + body=[ + {"index": {}}, + { + "timestamp": 1516729294000, + "temperature": 200, + "voltage": 5.2, + "node": "a", + }, + {"index": {}}, + { + "timestamp": 1516642894000, + "temperature": 201, + "voltage": 5.8, + "node": "b", + }, + {"index": {}}, + { + "timestamp": 1516556494000, + "temperature": 202, + "voltage": 5.1, + "node": "a", + }, + {"index": {}}, + { + "timestamp": 1516470094000, + "temperature": 198, + "voltage": 5.6, + "node": "b", + }, + {"index": {}}, + { + "timestamp": 1516383694000, + "temperature": 200, + "voltage": 4.2, + "node": "c", + }, + {"index": {}}, + { + "timestamp": 1516297294000, + "temperature": 202, + "voltage": 4, + "node": "c", + }, + ], +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/dea22bb4997e368950f0fc80f2a5f304.asciidoc b/docs/examples/dea22bb4997e368950f0fc80f2a5f304.asciidoc new file mode 100644 index 000000000..4b75ec23c --- /dev/null +++ b/docs/examples/dea22bb4997e368950f0fc80f2a5f304.asciidoc @@ -0,0 +1,10 @@ +// mapping/explicit-mapping.asciidoc:123 + +[source, python] +---- +resp = client.indices.get_field_mapping( + index="my-index-000001", + fields="employee-id", +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/e2883c88b5ceca9fce1e70e716d80025.asciidoc b/docs/examples/e2883c88b5ceca9fce1e70e716d80025.asciidoc new file mode 100644 index 000000000..844cc8fc0 --- /dev/null +++ b/docs/examples/e2883c88b5ceca9fce1e70e716d80025.asciidoc @@ -0,0 +1,10 @@ +// mapping/types/version.asciidoc:19 + +[source, python] +---- +resp = client.indices.create( + index="my-index-000001", + body={"mappings": {"properties": {"my_version": {"type": "version"}}}}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/e3678142aec988e2ff0ae5d934dc39e9.asciidoc b/docs/examples/e3678142aec988e2ff0ae5d934dc39e9.asciidoc new file mode 100644 index 000000000..267ba78e5 --- /dev/null +++ b/docs/examples/e3678142aec988e2ff0ae5d934dc39e9.asciidoc @@ -0,0 +1,76 @@ +// mapping/types/geo-point.asciidoc:28 + +[source, python] +---- +resp = client.indices.create( + index="my-index-000001", + body={"mappings": {"properties": {"location": {"type": "geo_point"}}}}, +) +print(resp) + +resp = client.index( + index="my-index-000001", + id="1", + body={ + "text": "Geopoint as an object using GeoJSON format", + "location": {"type": "Point", "coordinates": [-71.34, 41.12]}, + }, +) +print(resp) + +resp = client.index( + index="my-index-000001", + id="2", + body={ + "text": "Geopoint as a WKT POINT primitive", + "location": "POINT (-71.34 41.12)", + }, +) +print(resp) + +resp = client.index( + index="my-index-000001", + id="3", + body={ + "text": "Geopoint as an object with 'lat' and 'lon' keys", + "location": {"lat": 41.12, "lon": -71.34}, + }, +) +print(resp) + +resp = client.index( + index="my-index-000001", + id="4", + body={"text": "Geopoint as an array", "location": [-71.34, 41.12]}, +) +print(resp) + +resp = client.index( + index="my-index-000001", + id="5", + body={"text": "Geopoint as a string", "location": "41.12,-71.34"}, +) +print(resp) + +resp = client.index( + index="my-index-000001", + id="6", + body={"text": "Geopoint as a geohash", "location": "drm3btev3e86"}, +) +print(resp) + +resp = client.search( + index="my-index-000001", + body={ + "query": { + "geo_bounding_box": { + "location": { + "top_left": {"lat": 42, "lon": -72}, + "bottom_right": {"lat": 40, "lon": -74}, + } + } + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/e3f2f6ee3e312b8a90634827ae954d70.asciidoc b/docs/examples/e3f2f6ee3e312b8a90634827ae954d70.asciidoc new file mode 100644 index 000000000..f38cbc55d --- /dev/null +++ b/docs/examples/e3f2f6ee3e312b8a90634827ae954d70.asciidoc @@ -0,0 +1,21 @@ +// mapping/types/geo-shape.asciidoc:422 + +[source, python] +---- +resp = client.index( + index="example", + body={ + "location": { + "type": "GeometryCollection", + "geometries": [ + {"type": "Point", "coordinates": [100, 0]}, + { + "type": "LineString", + "coordinates": [[101, 0], [102, 1]], + }, + ], + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/e41a9bac42d0c1cb103674ae9039b7af.asciidoc b/docs/examples/e41a9bac42d0c1cb103674ae9039b7af.asciidoc new file mode 100644 index 000000000..b848ea87d --- /dev/null +++ b/docs/examples/e41a9bac42d0c1cb103674ae9039b7af.asciidoc @@ -0,0 +1,17 @@ +// mapping/dynamic/field-mapping.asciidoc:234 + +[source, python] +---- +resp = client.indices.create( + index="my-index-000001", + body={"mappings": {"numeric_detection": True}}, +) +print(resp) + +resp = client.index( + index="my-index-000001", + id="1", + body={"my_float": "1.0", "my_integer": "1"}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/e566e898902e432bc7ea0568400f0c50.asciidoc b/docs/examples/e566e898902e432bc7ea0568400f0c50.asciidoc new file mode 100644 index 000000000..e348d0842 --- /dev/null +++ b/docs/examples/e566e898902e432bc7ea0568400f0c50.asciidoc @@ -0,0 +1,30 @@ +// mapping/types/ip.asciidoc:170 + +[source, python] +---- +resp = client.indices.create( + index="idx", + body={ + "mappings": { + "_source": {"mode": "synthetic"}, + "properties": {"ip": {"type": "ip"}}, + } + }, +) +print(resp) + +resp = client.index( + index="idx", + id="1", + body={ + "ip": [ + "192.168.0.1", + "192.168.0.1", + "10.10.12.123", + "2001:db8::1:0:0:1", + "::afff:4567:890a", + ] + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/e63cf08350e9381f519c2835843be7cd.asciidoc b/docs/examples/e63cf08350e9381f519c2835843be7cd.asciidoc new file mode 100644 index 000000000..4bc711121 --- /dev/null +++ b/docs/examples/e63cf08350e9381f519c2835843be7cd.asciidoc @@ -0,0 +1,17 @@ +// mapping/dynamic/field-mapping.asciidoc:175 + +[source, python] +---- +resp = client.indices.create( + index="my-index-000001", + body={"mappings": {"dynamic_date_formats": ["yyyy/MM||MM/dd/yyyy"]}}, +) +print(resp) + +resp = client.index( + index="my-index-000001", + id="1", + body={"create_date": "09/25/2015"}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/e8a2726eea5545355d1d0835d4599f55.asciidoc b/docs/examples/e8a2726eea5545355d1d0835d4599f55.asciidoc new file mode 100644 index 000000000..7f7a0458d --- /dev/null +++ b/docs/examples/e8a2726eea5545355d1d0835d4599f55.asciidoc @@ -0,0 +1,10 @@ +// mapping/types/ip.asciidoc:126 + +[source, python] +---- +resp = client.search( + index="my-index-000001", + body={"query": {"term": {"ip_addr": "2001:db8::/48"}}}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/ea61aa2531ea73ccc0acd2d41f0518eb.asciidoc b/docs/examples/ea61aa2531ea73ccc0acd2d41f0518eb.asciidoc new file mode 100644 index 000000000..923f9eecb --- /dev/null +++ b/docs/examples/ea61aa2531ea73ccc0acd2d41f0518eb.asciidoc @@ -0,0 +1,33 @@ +// mapping/types/rank-feature.asciidoc:11 + +[source, python] +---- +resp = client.indices.create( + index="my-index-000001", + body={ + "mappings": { + "properties": { + "pagerank": {"type": "rank_feature"}, + "url_length": { + "type": "rank_feature", + "positive_score_impact": False, + }, + } + } + }, +) +print(resp) + +resp = client.index( + index="my-index-000001", + id="1", + body={"pagerank": 8, "url_length": 22}, +) +print(resp) + +resp = client.search( + index="my-index-000001", + body={"query": {"rank_feature": {"field": "pagerank"}}}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/eb33a7e5a0fe83fdaa0f79354f659428.asciidoc b/docs/examples/eb33a7e5a0fe83fdaa0f79354f659428.asciidoc new file mode 100644 index 000000000..2b29be190 --- /dev/null +++ b/docs/examples/eb33a7e5a0fe83fdaa0f79354f659428.asciidoc @@ -0,0 +1,19 @@ +// mapping/runtime.asciidoc:740 + +[source, python] +---- +resp = client.indices.put_mapping( + index="my-index-000001", + body={ + "runtime": { + "client_ip": { + "type": "ip", + "script": { + "source": 'String m = doc["message"].value; int end = m.indexOf(" "); emit(m.substring(0, end));' + }, + } + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/ed688d86eeaa4d7969acb0f574eb917f.asciidoc b/docs/examples/ed688d86eeaa4d7969acb0f574eb917f.asciidoc new file mode 100644 index 000000000..16fa1567e --- /dev/null +++ b/docs/examples/ed688d86eeaa4d7969acb0f574eb917f.asciidoc @@ -0,0 +1,12 @@ +// mapping/types/percolator.asciidoc:495 + +[source, python] +---- +resp = client.index( + index="my_queries1", + id="1", + refresh=True, + body={"query": {"term": {"my_field.prefix": "abc"}}}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/f09817fd13ff3dce52eb79d0722409c3.asciidoc b/docs/examples/f09817fd13ff3dce52eb79d0722409c3.asciidoc new file mode 100644 index 000000000..a872c1ce4 --- /dev/null +++ b/docs/examples/f09817fd13ff3dce52eb79d0722409c3.asciidoc @@ -0,0 +1,33 @@ +// mapping/types/percolator.asciidoc:115 + +[source, python] +---- +resp = client.indices.create( + index="new_index", + body={ + "mappings": { + "properties": { + "query": {"type": "percolator"}, + "body": {"type": "text"}, + } + } + }, +) +print(resp) + +resp = client.reindex( + refresh=True, + body={"source": {"index": "index"}, "dest": {"index": "new_index"}}, +) +print(resp) + +resp = client.indices.update_aliases( + body={ + "actions": [ + {"remove": {"index": "index", "alias": "queries"}}, + {"add": {"index": "new_index", "alias": "queries"}}, + ] + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/f3574cfee3971d98417b8dc574a91be0.asciidoc b/docs/examples/f3574cfee3971d98417b8dc574a91be0.asciidoc new file mode 100644 index 000000000..9d0bf459c --- /dev/null +++ b/docs/examples/f3574cfee3971d98417b8dc574a91be0.asciidoc @@ -0,0 +1,30 @@ +// mapping/types/flattened.asciidoc:367 + +[source, python] +---- +resp = client.indices.create( + index="idx", + body={ + "mappings": { + "_source": {"mode": "synthetic"}, + "properties": {"flattened": {"type": "flattened"}}, + } + }, +) +print(resp) + +resp = client.index( + index="idx", + id="1", + body={ + "flattened": { + "field": [ + {"id": 1, "name": "foo"}, + {"id": 2, "name": "bar"}, + {"id": 3, "name": "baz"}, + ] + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/f4c194628761a4cf2a01453a96bbcc3c.asciidoc b/docs/examples/f4c194628761a4cf2a01453a96bbcc3c.asciidoc new file mode 100644 index 000000000..9654b7b3d --- /dev/null +++ b/docs/examples/f4c194628761a4cf2a01453a96bbcc3c.asciidoc @@ -0,0 +1,41 @@ +// mapping/types/shape.asciidoc:344 + +[source, python] +---- +resp = client.index( + index="example", + body={ + "location": { + "type": "multipolygon", + "coordinates": [ + [ + [ + [1002, 200], + [1003, 200], + [1003, 300], + [1002, 300], + [1002, 200], + ] + ], + [ + [ + [1000, 200], + [1001, 100], + [1001, 100], + [1000, 100], + [1000, 100], + ], + [ + [1000.2, 200.2], + [1000.8, 100.2], + [1000.8, 100.8], + [1000.2, 100.8], + [1000.2, 100.2], + ], + ], + ], + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/f5eed3f2e3558a238487bc85305b7a71.asciidoc b/docs/examples/f5eed3f2e3558a238487bc85305b7a71.asciidoc new file mode 100644 index 000000000..1a23d66e8 --- /dev/null +++ b/docs/examples/f5eed3f2e3558a238487bc85305b7a71.asciidoc @@ -0,0 +1,12 @@ +// mapping/types/geo-shape.asciidoc:242 + +[source, python] +---- +resp = client.index( + index="example", + body={ + "location": "POLYGON ((100.0 0.0, 101.0 0.0, 101.0 1.0, 100.0 1.0, 100.0 0.0))" + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/f642b64e592131f37209a5100fe161cc.asciidoc b/docs/examples/f642b64e592131f37209a5100fe161cc.asciidoc new file mode 100644 index 000000000..9305917b6 --- /dev/null +++ b/docs/examples/f642b64e592131f37209a5100fe161cc.asciidoc @@ -0,0 +1,38 @@ +// mapping/dynamic/templates.asciidoc:425 + +[source, python] +---- +resp = client.indices.create( + index="my-index-000001", + body={ + "mappings": { + "dynamic_templates": [ + { + "named_analyzers": { + "match_mapping_type": "string", + "match": "*", + "mapping": {"type": "text", "analyzer": "{name}"}, + } + }, + { + "no_doc_values": { + "match_mapping_type": "*", + "mapping": { + "type": "{dynamic_type}", + "doc_values": False, + }, + } + }, + ] + } + }, +) +print(resp) + +resp = client.index( + index="my-index-000001", + id="1", + body={"english": "Some English text", "count": 5}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/f6c9d72fa26cbedd0c3f9fa64a88c38a.asciidoc b/docs/examples/f6c9d72fa26cbedd0c3f9fa64a88c38a.asciidoc new file mode 100644 index 000000000..02881fb4d --- /dev/null +++ b/docs/examples/f6c9d72fa26cbedd0c3f9fa64a88c38a.asciidoc @@ -0,0 +1,9 @@ +// mapping/types/alias.asciidoc:86 + +[source, python] +---- +resp = client.search( + body={"query": {"match_all": {}}, "_source": "route_length_miles"}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/f7726cc2c60dea26b88bf0df99fb0813.asciidoc b/docs/examples/f7726cc2c60dea26b88bf0df99fb0813.asciidoc new file mode 100644 index 000000000..e091bc6aa --- /dev/null +++ b/docs/examples/f7726cc2c60dea26b88bf0df99fb0813.asciidoc @@ -0,0 +1,10 @@ +// mapping/runtime.asciidoc:197 + +[source, python] +---- +resp = client.indices.create( + index="my-index-000001", + body={"mappings": {"runtime": {"day_of_week": {"type": "keyword"}}}}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/f9a315ea99bed0cf2f36be1d74eb3e4a.asciidoc b/docs/examples/f9a315ea99bed0cf2f36be1d74eb3e4a.asciidoc new file mode 100644 index 000000000..11bd78c61 --- /dev/null +++ b/docs/examples/f9a315ea99bed0cf2f36be1d74eb3e4a.asciidoc @@ -0,0 +1,12 @@ +// mapping/types/geo-shape.asciidoc:408 + +[source, python] +---- +resp = client.index( + index="example", + body={ + "location": "MULTIPOLYGON (((102.0 2.0, 103.0 2.0, 103.0 3.0, 102.0 3.0, 102.0 2.0)), ((100.0 0.0, 101.0 0.0, 101.0 1.0, 100.0 1.0, 100.0 0.0), (100.2 0.2, 100.8 0.2, 100.8 0.8, 100.2 0.8, 100.2 0.2)))" + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/f9ee5d55a73f4c1fe7d507609047aefd.asciidoc b/docs/examples/f9ee5d55a73f4c1fe7d507609047aefd.asciidoc new file mode 100644 index 000000000..63aa9fabf --- /dev/null +++ b/docs/examples/f9ee5d55a73f4c1fe7d507609047aefd.asciidoc @@ -0,0 +1,22 @@ +// mapping/types/search-as-you-type.asciidoc:87 + +[source, python] +---- +resp = client.search( + index="my-index-000001", + body={ + "query": { + "multi_match": { + "query": "brown f", + "type": "bool_prefix", + "fields": [ + "my_field", + "my_field._2gram", + "my_field._3gram", + ], + } + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/fab4b811ba968aa4df92fb1ac059ea31.asciidoc b/docs/examples/fab4b811ba968aa4df92fb1ac059ea31.asciidoc new file mode 100644 index 000000000..89c323c6f --- /dev/null +++ b/docs/examples/fab4b811ba968aa4df92fb1ac059ea31.asciidoc @@ -0,0 +1,10 @@ +// mapping/types/geo-shape.asciidoc:107 + +[source, python] +---- +resp = client.indices.create( + index="example", + body={"mappings": {"properties": {"location": {"type": "geo_shape"}}}}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/fb3505d976283fb7c7b9705a761e0dc2.asciidoc b/docs/examples/fb3505d976283fb7c7b9705a761e0dc2.asciidoc new file mode 100644 index 000000000..86be61a24 --- /dev/null +++ b/docs/examples/fb3505d976283fb7c7b9705a761e0dc2.asciidoc @@ -0,0 +1,24 @@ +// mapping/types/shape.asciidoc:264 + +[source, python] +---- +resp = client.index( + index="example", + body={ + "location": { + "type": "polygon", + "orientation": "clockwise", + "coordinates": [ + [ + [1000, 1000], + [1000, 1001], + [1001, 1001], + [1001, 1000], + [1000, 1000], + ] + ], + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/fc51fbc60b0e20aac83300a43ad90252.asciidoc b/docs/examples/fc51fbc60b0e20aac83300a43ad90252.asciidoc new file mode 100644 index 000000000..a9c081b8a --- /dev/null +++ b/docs/examples/fc51fbc60b0e20aac83300a43ad90252.asciidoc @@ -0,0 +1,21 @@ +// mapping/types/shape.asciidoc:375 + +[source, python] +---- +resp = client.index( + index="example", + body={ + "location": { + "type": "geometrycollection", + "geometries": [ + {"type": "point", "coordinates": [1000, 100]}, + { + "type": "linestring", + "coordinates": [[1001, 100], [1002, 100]], + }, + ], + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/fdada036a875d7995d5d7aba9c06361e.asciidoc b/docs/examples/fdada036a875d7995d5d7aba9c06361e.asciidoc new file mode 100644 index 000000000..0401b9146 --- /dev/null +++ b/docs/examples/fdada036a875d7995d5d7aba9c06361e.asciidoc @@ -0,0 +1,20 @@ +// mapping/types/dense-vector.asciidoc:95 + +[source, python] +---- +resp = client.indices.create( + index="my-index-2", + body={ + "mappings": { + "properties": { + "my_vector": { + "type": "dense_vector", + "dims": 3, + "index": False, + } + } + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/fe7169bab8e626f582c9ea87585d0f35.asciidoc b/docs/examples/fe7169bab8e626f582c9ea87585d0f35.asciidoc new file mode 100644 index 000000000..dc1e04c17 --- /dev/null +++ b/docs/examples/fe7169bab8e626f582c9ea87585d0f35.asciidoc @@ -0,0 +1,17 @@ +// mapping/types/histogram.asciidoc:99 + +[source, python] +---- +resp = client.indices.create( + index="my-index-000001", + body={ + "mappings": { + "properties": { + "my_histogram": {"type": "histogram"}, + "my_text": {"type": "keyword"}, + } + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/ff1b96d2fdcf628bd938bff9e939943c.asciidoc b/docs/examples/ff1b96d2fdcf628bd938bff9e939943c.asciidoc new file mode 100644 index 000000000..f3b2889cf --- /dev/null +++ b/docs/examples/ff1b96d2fdcf628bd938bff9e939943c.asciidoc @@ -0,0 +1,19 @@ +// mapping/runtime.asciidoc:967 + +[source, python] +---- +resp = client.indices.create( + index="my-index-000001", + body={ + "mappings": { + "properties": { + "timestamp": {"type": "date"}, + "temperature": {"type": "long"}, + "voltage": {"type": "double"}, + "node": {"type": "keyword"}, + } + } + }, +) +print(resp) +---- \ No newline at end of file diff --git a/utils/generate-examples.py b/utils/generate-examples.py index 12a69f15a..39fdc0973 100644 --- a/utils/generate-examples.py +++ b/utils/generate-examples.py @@ -154,6 +154,41 @@ "index-modules/store.asciidoc", "index-modules/index-sorting.asciidoc", "index-modules/indexing-pressure.asciidoc", + "mapping/dynamic-mapping.asciidoc", + "mapping/dynamic/field-mapping.asciidoc", + "mapping/dynamic/templates.asciidoc", + "mapping/explicit-mapping.asciidoc", + "mapping/runtime.asciidoc", + "mapping/runtime.asciidoc", + "mapping/types.asciidoc", + "mapping/types/aggregate-metric-double.asciidoc", + "mapping/types/alias.asciidoc", + "mapping/types/array.asciidoc", + "mapping/types/binary.asciidoc", + "mapping/types/boolean.asciidoc", + "mapping/types/completion.asciidoc", + "mapping/types/date_nanos.asciidoc", + "mapping/types/dense-vector.asciidoc", + "mapping/types/flattened.asciidoc", + "mapping/types/geo-point.asciidoc", + "mapping/types/geo-shape.asciidoc", + "mapping/types/histogram.asciidoc", + "mapping/types/ip.asciidoc", + "mapping/types/parent-join.asciidoc", + "mapping/types/object.asciidoc", + "mapping/types/percolator.asciidoc", + "mapping/types/point.asciidoc", + "mapping/types/range.asciidoc", + "mapping/types/rank-feature.asciidoc", + "mapping/types/rank-features.asciidoc", + "mapping/types/search-as-you-type.asciidoc", + "mapping/types/semantic-text.asciidoc", + "mapping/types/shape.asciidoc", + "mapping/types/sparse-vector.asciidoc", + "mapping/types/text.asciidoc", + "mapping/types/token-count.asciidoc", + "mapping/types/unsigned_long.asciidoc", + "mapping/types/version.asciidoc", ]