doc examples for index, del, get & getting started
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
'''
|
||||
Licensed to Elasticsearch B.V under one or more agreements.
|
||||
Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
See the LICENSE file in the project root for more information
|
||||
'''
|
||||
|
||||
from elasticsearch import Elasticsearch
|
||||
|
||||
es = Elasticsearch()
|
||||
|
||||
print("c5e5873783246c7b1c01d8464fed72c4 - L:9")
|
||||
# tag::c5e5873783246c7b1c01d8464fed72c4[]
|
||||
response = es.delete(
|
||||
index='twitter',
|
||||
id=1,
|
||||
)
|
||||
# end::c5e5873783246c7b1c01d8464fed72c4[]
|
||||
print("---------------------------------------")
|
||||
print(response)
|
||||
print("---------------------------------------")
|
||||
|
||||
print("47b5ff897f26e9c943cee5c06034181d - L:84")
|
||||
# tag::47b5ff897f26e9c943cee5c06034181d[]
|
||||
response = es.delete(
|
||||
index='twitter',
|
||||
id=1,
|
||||
routing='kimchy',
|
||||
)
|
||||
# end::47b5ff897f26e9c943cee5c06034181d[]
|
||||
print("---------------------------------------")
|
||||
print(response)
|
||||
print("---------------------------------------")
|
||||
|
||||
print("d90a84a24a407731dfc1929ac8327746 - L:147")
|
||||
# tag::d90a84a24a407731dfc1929ac8327746[]
|
||||
response = es.delete(
|
||||
index='twitter',
|
||||
id=1,
|
||||
timeout='5m',
|
||||
)
|
||||
# end::d90a84a24a407731dfc1929ac8327746[]
|
||||
print("---------------------------------------")
|
||||
print(response)
|
||||
print("---------------------------------------")
|
||||
@@ -0,0 +1,168 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
'''
|
||||
Licensed to Elasticsearch B.V under one or more agreements.
|
||||
Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
See the LICENSE file in the project root for more information
|
||||
'''
|
||||
|
||||
from elasticsearch import Elasticsearch
|
||||
|
||||
es = Elasticsearch()
|
||||
|
||||
print("fbcf5078a6a9e09790553804054c36b3 - L:9")
|
||||
# tag::fbcf5078a6a9e09790553804054c36b3[]
|
||||
response = es.get(
|
||||
index='twitter',
|
||||
id=0,
|
||||
)
|
||||
# end::fbcf5078a6a9e09790553804054c36b3[]
|
||||
print("---------------------------------------")
|
||||
print(response)
|
||||
print("---------------------------------------")
|
||||
|
||||
print("98234499cfec70487cec5d013e976a84 - L:46")
|
||||
# tag::98234499cfec70487cec5d013e976a84[]
|
||||
response = es.exists(
|
||||
index='twitter',
|
||||
id=0,
|
||||
)
|
||||
# end::98234499cfec70487cec5d013e976a84[]
|
||||
print("---------------------------------------")
|
||||
print(response)
|
||||
print("---------------------------------------")
|
||||
|
||||
print("138ccd89f72aa7502dd9578403dcc589 - L:72")
|
||||
# tag::138ccd89f72aa7502dd9578403dcc589[]
|
||||
response = es.get(
|
||||
index='twitter',
|
||||
id=0,
|
||||
_source=False,
|
||||
)
|
||||
# end::138ccd89f72aa7502dd9578403dcc589[]
|
||||
print("---------------------------------------")
|
||||
print(response)
|
||||
print("---------------------------------------")
|
||||
|
||||
print("8fdf2344c4fb3de6902ad7c5735270df - L:84")
|
||||
# tag::8fdf2344c4fb3de6902ad7c5735270df[]
|
||||
response = es.get(
|
||||
index='twitter',
|
||||
id=0,
|
||||
_source_includes='*.id',
|
||||
_source_excludes='entities',
|
||||
)
|
||||
# end::8fdf2344c4fb3de6902ad7c5735270df[]
|
||||
print("---------------------------------------")
|
||||
print(response)
|
||||
print("---------------------------------------")
|
||||
|
||||
print("745f9b8cdb8e91073f6e520e1d9f8c05 - L:93")
|
||||
# tag::745f9b8cdb8e91073f6e520e1d9f8c05[]
|
||||
response = es.get(
|
||||
index='twitter',
|
||||
id=0,
|
||||
_source='*.id,retweeted',
|
||||
)
|
||||
# end::745f9b8cdb8e91073f6e520e1d9f8c05[]
|
||||
print("---------------------------------------")
|
||||
print(response)
|
||||
print("---------------------------------------")
|
||||
|
||||
print("913770050ebbf3b9b549a899bc11060a - L:109")
|
||||
print("TODO")
|
||||
|
||||
print("5eabcdbf61bfcb484dc694f25c2bba36 - L:131")
|
||||
# tag::5eabcdbf61bfcb484dc694f25c2bba36[]
|
||||
response = es.index(
|
||||
index='twitter',
|
||||
id=1,
|
||||
body={
|
||||
'counter': 1,
|
||||
'tags': ['red'],
|
||||
},
|
||||
)
|
||||
# end::5eabcdbf61bfcb484dc694f25c2bba36[]
|
||||
print("---------------------------------------")
|
||||
print(response)
|
||||
print("---------------------------------------")
|
||||
|
||||
print("710c7871f20f176d51209b1574b0d61b - L:144")
|
||||
# tag::710c7871f20f176d51209b1574b0d61b[]
|
||||
response = es.get(
|
||||
index='twitter',
|
||||
id=1,
|
||||
stored_fields='tags,counter',
|
||||
)
|
||||
# end::710c7871f20f176d51209b1574b0d61b[]
|
||||
print("---------------------------------------")
|
||||
print(response)
|
||||
print("---------------------------------------")
|
||||
|
||||
print("0ba0b2db24852abccb7c0fc1098d566e - L:178")
|
||||
# tag::0ba0b2db24852abccb7c0fc1098d566e[]
|
||||
response = es.index(
|
||||
index='twitter',
|
||||
id=1,
|
||||
body={
|
||||
'counter': 1,
|
||||
'tags': ['white'],
|
||||
},
|
||||
routing='user1',
|
||||
)
|
||||
# end::0ba0b2db24852abccb7c0fc1098d566e[]
|
||||
print("---------------------------------------")
|
||||
print(response)
|
||||
print("---------------------------------------")
|
||||
|
||||
print("69a7be47f85138b10437113ab2f0d72d - L:189")
|
||||
# tag::69a7be47f85138b10437113ab2f0d72d[]
|
||||
response = es.get(
|
||||
index='twitter',
|
||||
id=2,
|
||||
routing='user1',
|
||||
stored_fields='tags,counter',
|
||||
)
|
||||
# end::69a7be47f85138b10437113ab2f0d72d[]
|
||||
print("---------------------------------------")
|
||||
print(response)
|
||||
print("---------------------------------------")
|
||||
|
||||
print("89a8ac1509936acc272fc2d72907bc45 - L:229")
|
||||
# tag::89a8ac1509936acc272fc2d72907bc45[]
|
||||
response = es.get_source(
|
||||
index='twitter',
|
||||
id=1,
|
||||
)
|
||||
# end::89a8ac1509936acc272fc2d72907bc45[]
|
||||
print("---------------------------------------")
|
||||
print(response)
|
||||
print("---------------------------------------")
|
||||
|
||||
print("d222c6a6ec7a3beca6c97011b0874512 - L:238")
|
||||
# tag::d222c6a6ec7a3beca6c97011b0874512[]
|
||||
response = es.get_source(
|
||||
index='twitter',
|
||||
id=1,
|
||||
_source_includes='*.id',
|
||||
_source_excludes='entities',
|
||||
)
|
||||
# end::d222c6a6ec7a3beca6c97011b0874512[]
|
||||
print("---------------------------------------")
|
||||
print(response)
|
||||
print("---------------------------------------")
|
||||
|
||||
print("2468ab381257d759d8a88af1141f6f9c - L:248")
|
||||
print("TODO")
|
||||
|
||||
print("1d65cb6d055c46a1bde809687d835b71 - L:262")
|
||||
# tag::1d65cb6d055c46a1bde809687d835b71[]
|
||||
response = es.get(
|
||||
index='twitter',
|
||||
id=1,
|
||||
routing='user1',
|
||||
)
|
||||
# end::1d65cb6d055c46a1bde809687d835b71[]
|
||||
print("---------------------------------------")
|
||||
print(response)
|
||||
print("---------------------------------------")
|
||||
@@ -0,0 +1,130 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
'''
|
||||
Licensed to Elasticsearch B.V under one or more agreements.
|
||||
Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
See the LICENSE file in the project root for more information
|
||||
'''
|
||||
|
||||
from elasticsearch import Elasticsearch
|
||||
|
||||
es = Elasticsearch()
|
||||
|
||||
print("bb143628fd04070683eeeadc9406d9cc - L:11")
|
||||
# tag::bb143628fd04070683eeeadc9406d9cc[]
|
||||
response = es.index(
|
||||
index='twitter',
|
||||
id=1,
|
||||
body={
|
||||
'user': 'kimchy',
|
||||
'post_date': '2009-11-15T14:12:12',
|
||||
'message': 'trying out Elasticsearch',
|
||||
}
|
||||
)
|
||||
# end::bb143628fd04070683eeeadc9406d9cc[]
|
||||
print("---------------------------------------")
|
||||
print(response)
|
||||
print("---------------------------------------")
|
||||
|
||||
print("804a97ff4d0613e6568e4efb19c52021 - L:77")
|
||||
print("TODO")
|
||||
|
||||
print("d718b63cf1b6591a1d59a0cf4fd995eb - L:121")
|
||||
# tag::d718b63cf1b6591a1d59a0cf4fd995eb[]
|
||||
response = es.index(
|
||||
index='twitter',
|
||||
id=1,
|
||||
body={
|
||||
'user': 'kimchy',
|
||||
'post_date': '2009-11-15T14:12:12',
|
||||
'message': 'trying out Elasticsearch',
|
||||
},
|
||||
op_type='create',
|
||||
)
|
||||
# end::d718b63cf1b6591a1d59a0cf4fd995eb[]
|
||||
print("---------------------------------------")
|
||||
print(response)
|
||||
print("---------------------------------------")
|
||||
|
||||
print("048d8abd42d094bbdcf4452a58ccb35b - L.:134")
|
||||
# tag::048d8abd42d094bbdcf4452a58ccb35b[]
|
||||
response = es.create(
|
||||
index='twitter',
|
||||
id=1,
|
||||
body={
|
||||
'user': 'kimchy',
|
||||
'post_date': '2009-11-15T14:12:12',
|
||||
'message': 'trying out Elasticsearch',
|
||||
}
|
||||
)
|
||||
# end::048d8abd42d094bbdcf4452a58ccb35b[]
|
||||
print("---------------------------------------")
|
||||
print(response)
|
||||
print("---------------------------------------")
|
||||
|
||||
print("36818c6d9f434d387819c30bd9addb14 - L:153")
|
||||
# tag::36818c6d9f434d387819c30bd9addb14[]
|
||||
response = es.index(
|
||||
index='twitter',
|
||||
body={
|
||||
'user': 'kimchy',
|
||||
'post_date': '2009-11-15T14:12:12',
|
||||
'message': 'trying out Elasticsearch',
|
||||
}
|
||||
)
|
||||
# end::36818c6d9f434d387819c30bd9addb14[]
|
||||
print("---------------------------------------")
|
||||
print(response)
|
||||
print("---------------------------------------")
|
||||
|
||||
print("625dc94df1f9affb49a082fd99d41620 - L:204")
|
||||
# tag::625dc94df1f9affb49a082fd99d41620[]
|
||||
response = es.index(
|
||||
index='twitter',
|
||||
id=1,
|
||||
body={
|
||||
'user': 'kimchy',
|
||||
'post_date': '2009-11-15T14:12:12',
|
||||
'message': 'trying out Elasticsearch',
|
||||
},
|
||||
routing='kimchy',
|
||||
)
|
||||
# end::625dc94df1f9affb49a082fd99d41620[]
|
||||
print("---------------------------------------")
|
||||
print(response)
|
||||
print("---------------------------------------")
|
||||
|
||||
print("b918d6b798da673a33e49b94f61dcdc0 - L:327")
|
||||
# tag::b918d6b798da673a33e49b94f61dcdc0[]
|
||||
response = es.index(
|
||||
index='twitter',
|
||||
id=1,
|
||||
body={
|
||||
'user': 'kimchy',
|
||||
'post_date': '2009-11-15T14:12:12',
|
||||
'message': 'trying out Elasticsearch',
|
||||
},
|
||||
timeout='5m',
|
||||
)
|
||||
# end::b918d6b798da673a33e49b94f61dcdc0[]
|
||||
print("---------------------------------------")
|
||||
print(response)
|
||||
print("---------------------------------------")
|
||||
|
||||
print("1f336ecc62480c1d56351cc2f82d0d08 - L:357")
|
||||
# tag::1f336ecc62480c1d56351cc2f82d0d08[]
|
||||
response = es.index(
|
||||
index='twitter',
|
||||
id=1,
|
||||
body={
|
||||
'user': 'kimchy',
|
||||
'post_date': '2009-11-15T14:12:12',
|
||||
'message': 'trying out Elasticsearch',
|
||||
},
|
||||
version=2,
|
||||
version_type='external',
|
||||
)
|
||||
# end::1f336ecc62480c1d56351cc2f82d0d08[]
|
||||
print("---------------------------------------")
|
||||
print(response)
|
||||
print("---------------------------------------")
|
||||
@@ -0,0 +1,338 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
'''
|
||||
Licensed to Elasticsearch B.V under one or more agreements.
|
||||
Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
See the LICENSE file in the project root for more information
|
||||
'''
|
||||
|
||||
from elasticsearch import Elasticsearch
|
||||
|
||||
es = Elasticsearch()
|
||||
|
||||
print("f8cc4b331a19ff4df8e4a490f906ee69 - L: 209")
|
||||
# tag::f8cc4b331a19ff4df8e4a490f906ee69[]
|
||||
response = es.cat.health(v=True)
|
||||
# end::f8cc4b331a19ff4df8e4a490f906ee69[]
|
||||
print("---------------------------------------")
|
||||
print(response)
|
||||
print("---------------------------------------")
|
||||
|
||||
print("db20adb70a8e8d0709d15ba0daf18d23 - L:240")
|
||||
# tag::db20adb70a8e8d0709d15ba0daf18d23[]
|
||||
response = es.cat.nodes(v=True)
|
||||
# end::db20adb70a8e8d0709d15ba0daf18d23[]
|
||||
print("---------------------------------------")
|
||||
print(response)
|
||||
print("---------------------------------------")
|
||||
|
||||
print("c3fa04519df668d6c27727a12ab09648 - L:263")
|
||||
# tag::c3fa04519df668d6c27727a12ab09648[]
|
||||
response = es.cat.indices(v=True)
|
||||
# end::c3fa04519df668d6c27727a12ab09648[]
|
||||
print("---------------------------------------")
|
||||
print(response)
|
||||
print("---------------------------------------")
|
||||
|
||||
print("0caf6b6b092ecbcf6f996053678a2384 - L:284")
|
||||
# tag::0caf6b6b092ecbcf6f996053678a2384[]
|
||||
# // PUT /customer?pretty
|
||||
response = es.cat.indices(v=True)
|
||||
# end::0caf6b6b092ecbcf6f996053678a2384[]
|
||||
print("---------------------------------------")
|
||||
print(response)
|
||||
print("---------------------------------------")
|
||||
|
||||
print("21fe98843fe0b5473f515d21803db409 - L:311")
|
||||
# tag::21fe98843fe0b5473f515d21803db409[]
|
||||
response = es.index(
|
||||
index='customer',
|
||||
id=1,
|
||||
body={
|
||||
'name': 'John Doe',
|
||||
}
|
||||
)
|
||||
# end::21fe98843fe0b5473f515d21803db409[]
|
||||
print("---------------------------------------")
|
||||
print(response)
|
||||
print("---------------------------------------")
|
||||
|
||||
print("37a3b66b555aed55618254f50d572cd6 - L:347")
|
||||
# tag::37a3b66b555aed55618254f50d572cd6[]
|
||||
response = es.get(
|
||||
index='customer',
|
||||
id=1,
|
||||
)
|
||||
# end::37a3b66b555aed55618254f50d572cd6[]
|
||||
print("---------------------------------------")
|
||||
print(response)
|
||||
print("---------------------------------------")
|
||||
|
||||
print("92e3c75133dc4fdb2cc65f149001b40b - L:378")
|
||||
# tag::92e3c75133dc4fdb2cc65f149001b40b[]
|
||||
es.indices.delete(index='customer')
|
||||
response = es.cat.indices(v=True)
|
||||
# end::92e3c75133dc4fdb2cc65f149001b40b[]
|
||||
print("---------------------------------------")
|
||||
print(response)
|
||||
print("---------------------------------------")
|
||||
|
||||
print("fa5f618ced25ed2e67a1439bb77ba340 - L:398")
|
||||
# tag::fa5f618ced25ed2e67a1439bb77ba340[]
|
||||
response = es.index(
|
||||
index='customer',
|
||||
id=1,
|
||||
body={
|
||||
'name': 'John Doe',
|
||||
}
|
||||
)
|
||||
response = es.get(
|
||||
index='customer',
|
||||
id=1,
|
||||
)
|
||||
es.indices.delete(index='customer')
|
||||
# end::fa5f618ced25ed2e67a1439bb77ba340[]
|
||||
print("---------------------------------------")
|
||||
print(response)
|
||||
print("---------------------------------------")
|
||||
|
||||
print("21fe98843fe0b5473f515d21803db409 - L:431")
|
||||
# tag::21fe98843fe0b5473f515d21803db409[]
|
||||
response = es.index(
|
||||
index='customer',
|
||||
id=1,
|
||||
body={
|
||||
'name': 'John Doe',
|
||||
}
|
||||
)
|
||||
# end::21fe98843fe0b5473f515d21803db409[]
|
||||
print("---------------------------------------")
|
||||
print(response)
|
||||
print("---------------------------------------")
|
||||
|
||||
print("75bda7da7fefff2c16f0423a9aa41c6e - L:442")
|
||||
# tag::75bda7da7fefff2c16f0423a9aa41c6e[]
|
||||
response = es.index(
|
||||
index='customer',
|
||||
id=2,
|
||||
body={
|
||||
'name': 'Jane Doe',
|
||||
}
|
||||
)
|
||||
# end::75bda7da7fefff2c16f0423a9aa41c6e[]
|
||||
print("---------------------------------------")
|
||||
print(response)
|
||||
print("---------------------------------------")
|
||||
|
||||
print("37c778346eb67042df5e8edf2485e40a - L:454")
|
||||
# tag::37c778346eb67042df5e8edf2485e40a[]
|
||||
response = es.index(
|
||||
index='customer',
|
||||
body={
|
||||
'name': 'Jane Doe',
|
||||
}
|
||||
)
|
||||
# end::37c778346eb67042df5e8edf2485e40a[]
|
||||
print("---------------------------------------")
|
||||
print(response)
|
||||
print("---------------------------------------")
|
||||
|
||||
print("1c0f3b0bc4b7e53b53755fd3bda5b8cf - L:470")
|
||||
# tag::1c0f3b0bc4b7e53b53755fd3bda5b8cf[]
|
||||
response = es.index(
|
||||
index='customer',
|
||||
body={
|
||||
'name': 'Jane Doe',
|
||||
}
|
||||
)
|
||||
# end::1c0f3b0bc4b7e53b53755fd3bda5b8cf[]
|
||||
print("---------------------------------------")
|
||||
print(response)
|
||||
print("---------------------------------------")
|
||||
|
||||
|
||||
print("6a8d7b34f2b42d5992aaa1ff147062d9 - L:489")
|
||||
# tag::6a8d7b34f2b42d5992aaa1ff147062d9[]
|
||||
response = es.update(
|
||||
index='customer',
|
||||
id=1,
|
||||
body={
|
||||
'doc': {
|
||||
'name': 'Jane Doe',
|
||||
},
|
||||
},
|
||||
)
|
||||
# end::6a8d7b34f2b42d5992aaa1ff147062d9[]
|
||||
print("---------------------------------------")
|
||||
print(response)
|
||||
print("---------------------------------------")
|
||||
|
||||
print("731621af937d66170347b9cc6b4a3c48 - L:501")
|
||||
# tag::731621af937d66170347b9cc6b4a3c48[]
|
||||
response = es.update(
|
||||
index='customer',
|
||||
id=1,
|
||||
body={
|
||||
'doc': {
|
||||
'name': 'Jane Doe',
|
||||
'age': 20,
|
||||
},
|
||||
},
|
||||
)
|
||||
# end::731621af937d66170347b9cc6b4a3c48[]
|
||||
print("---------------------------------------")
|
||||
print(response)
|
||||
print("---------------------------------------")
|
||||
|
||||
print("38dfa309717488362d0f784e17ebd1b5 - L:513")
|
||||
print("TODO")
|
||||
|
||||
print("9c5ef83db886840355ff662b6e9ae8ab - L:532")
|
||||
# tag::9c5ef83db886840355ff662b6e9ae8ab[]
|
||||
response = es.delete(
|
||||
index='customer',
|
||||
id=2,
|
||||
)
|
||||
# end::9c5ef83db886840355ff662b6e9ae8ab[]
|
||||
print("---------------------------------------")
|
||||
print(response)
|
||||
print("---------------------------------------")
|
||||
|
||||
print("7d32a32357b5ea8819b72608fcc6fd07 - L:550")
|
||||
# tag::7d32a32357b5ea8819b72608fcc6fd07[]
|
||||
response = es.bulk(body=[
|
||||
{'index': {'_index': 'customer', '_id': 1}},
|
||||
{'name': 'John Doe'},
|
||||
{'index': {'_index': 'customer', '_id': 2}},
|
||||
{'name': 'Jane Doe'},
|
||||
])
|
||||
# end::7d32a32357b5ea8819b72608fcc6fd07[]
|
||||
print("---------------------------------------")
|
||||
print(response)
|
||||
print("---------------------------------------")
|
||||
|
||||
print("193864342d9f0a36ec84a91ca325f5ec - L:562")
|
||||
# tag::193864342d9f0a36ec84a91ca325f5ec[]
|
||||
response = es.bulk(body=[
|
||||
{'index': {'_index': 'customer', '_id': 1}},
|
||||
{'name': 'John Doe'},
|
||||
{'delete': {'_index': 'customer', '_id': 2}},
|
||||
])
|
||||
# end::193864342d9f0a36ec84a91ca325f5ec[]
|
||||
print("---------------------------------------")
|
||||
print(response)
|
||||
print("---------------------------------------")
|
||||
|
||||
print("c181969ef91c3b4a2513c1885be98e26 - L:647")
|
||||
# tag::c181969ef91c3b4a2513c1885be98e26[]
|
||||
response = es.search(
|
||||
index='bank',
|
||||
q='*',
|
||||
sort={
|
||||
'account_number': 'asc',
|
||||
},
|
||||
)
|
||||
# end::c181969ef91c3b4a2513c1885be98e26[]
|
||||
print("---------------------------------------")
|
||||
print(response)
|
||||
print("---------------------------------------")
|
||||
|
||||
print("506844befdc5691d835771bcbb1c1a60 - L:720")
|
||||
# tag::506844befdc5691d835771bcbb1c1a60[]
|
||||
response = es.search(
|
||||
index='bank',
|
||||
body={
|
||||
'query': {
|
||||
'match_all': {},
|
||||
},
|
||||
},
|
||||
sort={
|
||||
'account_number': 'asc',
|
||||
},
|
||||
)
|
||||
# end::506844befdc5691d835771bcbb1c1a60[]
|
||||
print("---------------------------------------")
|
||||
print(response)
|
||||
print("---------------------------------------")
|
||||
|
||||
print("345ea7e9cb5af9e052ce0cf6f1f52c23 - L:789")
|
||||
# tag::345ea7e9cb5af9e052ce0cf6f1f52c23[]
|
||||
response = es.search(
|
||||
index='bank',
|
||||
body={
|
||||
'query': {
|
||||
'match_all': {},
|
||||
},
|
||||
},
|
||||
)
|
||||
# end::345ea7e9cb5af9e052ce0cf6f1f52c23[]
|
||||
print("---------------------------------------")
|
||||
print(response)
|
||||
print("---------------------------------------")
|
||||
|
||||
print("3d7527bb7ac3b0e1f97b22bdfeb99070 - L:805")
|
||||
# tag::3d7527bb7ac3b0e1f97b22bdfeb99070[]
|
||||
response = es.search(
|
||||
index='bank',
|
||||
body={
|
||||
'query': {
|
||||
'match_all': {},
|
||||
},
|
||||
},
|
||||
size=1,
|
||||
)
|
||||
# end::3d7527bb7ac3b0e1f97b22bdfeb99070[]
|
||||
print("---------------------------------------")
|
||||
print(response)
|
||||
print("---------------------------------------")
|
||||
|
||||
print("3c31f9eb032861bff64abd8b14758991 - L:820")
|
||||
# tag::3c31f9eb032861bff64abd8b14758991[]
|
||||
response = es.search(
|
||||
index='bank',
|
||||
body={
|
||||
'query': {
|
||||
'match_all': {},
|
||||
},
|
||||
},
|
||||
from_=10,
|
||||
size=10,
|
||||
)
|
||||
# end::3c31f9eb032861bff64abd8b14758991[]
|
||||
print("---------------------------------------")
|
||||
print(response)
|
||||
print("---------------------------------------")
|
||||
|
||||
print("e8035a7476601ad4b136edb250f92d53 - L:836")
|
||||
# tag::e8035a7476601ad4b136edb250f92d53[]
|
||||
response = es.search(
|
||||
index='bank',
|
||||
body={
|
||||
'query': {
|
||||
'match_all': {},
|
||||
},
|
||||
},
|
||||
sort={
|
||||
'balance': 'desc',
|
||||
},
|
||||
)
|
||||
# end::e8035a7476601ad4b136edb250f92d53[]
|
||||
print("---------------------------------------")
|
||||
print(response)
|
||||
print("---------------------------------------")
|
||||
|
||||
print("b8459547da50aebddbcdd1aaaac02b5f - L:854")
|
||||
# tag::b8459547da50aebddbcdd1aaaac02b5f[]
|
||||
response = es.search(
|
||||
index='bank',
|
||||
body={
|
||||
'query': {
|
||||
'match_all': {},
|
||||
},
|
||||
},
|
||||
_source=['account_number', 'balance'],
|
||||
)
|
||||
# end::b8459547da50aebddbcdd1aaaac02b5f[]
|
||||
print("---------------------------------------")
|
||||
print(response)
|
||||
print("---------------------------------------")
|
||||
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
'''
|
||||
Licensed to Elasticsearch B.V under one or more agreements.
|
||||
Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
See the LICENSE file in the project root for more information
|
||||
'''
|
||||
|
||||
from elasticsearch import Elasticsearch
|
||||
|
||||
es = Elasticsearch()
|
||||
|
||||
print("3d1ff6097e2359f927c88c2ccdb36252 - L:7")
|
||||
# tag::3d1ff6097e2359f927c88c2ccdb36252[]
|
||||
response = es.info()
|
||||
# end::3d1ff6097e2359f927c88c2ccdb36252[]
|
||||
print("---------------------------------------")
|
||||
print(response)
|
||||
print("---------------------------------------")
|
||||
Reference in New Issue
Block a user