Package: elasticsearch-python-client
ElasticSearchPyAboutElasticSeachPy is a python library used to connect to and interact with elasticsearchThis library is a python implementation of the Elasticsearch HTTPAPIand an alternative to ElasticSearch's PythonLibraryInstallationElasticSearchPy can be install with the pip distribution system for Python by issuing:$ pip3 install elasticsearch-python-clientAlternatively, you can run use setup.py to install by cloning this repository and issuing:$ python3 setup.py installLimitationsThis library is currently under development and is not as feature rich as it will be.  This being said, it currently has several limitationsPython3+ Only- My primary development environment is python3, I currently do not have the time to test and vet interoperability between python2 and python3ElasticSearch Authentication- Currently, this library only supports "No Authentication" and "SSL w/ Certificate Authentication".  This limitation is simply due to my testing environmentsLimited Functionality- If functionality isn't listed here, it is either not implemented or is not tested.  As time moves forward, I will continue to add fuctionalityContributorsIf you are interested in contributing to this project, feel free to contact me atjeff@koebane.netExamplesConnecting to ElasticSearchfromelasticsearchpyimportElasticSearchConnectiones_ip="192.168.1.1"# Connect to the clusteres_conn=ElasticSearchConnection(es_ip)# Connect to the cluster with a non 9200 port# es_conn = ElasticSearchConnection(es_ip, port=80)# Alternatively Connect to the cluster using SSL certificates# es_conn = ElasticSearchConnection(es_ip, port=443,#    use_ssl=True,#    cert="/path/to/cert.crt",#    key="/path/to/key.key"#)Interact with the ClusterfromelasticsearchpyimportElasticSearchConnectiones_ip="192.168.1.1"# Connect to the clusteres_conn=ElasticSearchConnection(es_ip)#Get Cluster Objectes_cluster=es_conn.get_cluster()# get number of active shardsprint("There are{}active shards".format(es_cluster.active_shards))# Get the number of hoststotal_nodes=es_cluster.nodesdata_nodes=es_cluster.data_nodesprint("This cluster has{}nodes ({}data nodes )".format(total_nodes,data_nodes))# Get Node Namesnodes=es_cluster.node_namesprint("This cluster has the following nodes:")fornode_nameinnodes:print("-{}".format(node_name))Interact with a cluster nodefromelasticsearchpyimportElasticSearchConnectiones_ip="192.168.1.1"# Connect to the clusteres_conn=ElasticSearchConnection(es_ip)#Get Cluster Objectes_cluster=es_conn.get_cluster()# Get Node Namesnodes=es_cluster.node_names# Get Node Objectnode=es_cluster.get_node(nodes[0)print("Node{}".format(node.name)ifnode.master:print("* Is the master Node")ifnode.ingest_node:print("* Is an ingest Node")ifnode.data_node:print("* Is a data node")print("Elasticsearch Version:{}".format(node.version))print("OS:{}".format(node.os))print("Has the following roles")print("------------------------")forroleinnode.roles:print(" -{}".format(role))Interact with indicesfromelasticsearchpyimportElasticSearchConnectiones_ip="192.168.1.1"# Connect to the clusteres_conn=ElasticSearchConnection(es_ip)# Get Indices Objectnon_sys_indices=es_conn.get_indices()# this gets all non-system indicesall_indices=es_conn.get_indices(system_indices=True)# this gets all indices including system indicesbob_indices=es_conn.get_indices(indice_prefix="bob")# this gets all indices that start with bob# List indicesprint("Here are the non-system indices")forindiceinnon_sys_indices.indices:print("-{}".format(indice)print("Total:{}".format(non_sys_indices.count)# Create an indicemy_indice=indices.create_indice("bob-1")# Creates bob-1 with default shard replica valuesmy_indice2=indices.create_indice("bob-2",shards=2,replicas=0)# Creates bob-2 with 2 shards and 0 replicas# Delete an indiceindices.delete_indice("bob-2")# Deletes the Indice named bob-2Interact with a single indicefromelasticsearchpyimportElasticSearchConnectionfromelasticsearchpyimportElasticSearchIndicees_ip="192.168.1.1"# Connect to the clusteres_conn=ElasticSearchConnection(es_ip)# Get Indices Objectnon_sys_indices=es_conn.get_indices()# this gets all non-system indices# Get the Indice Objectmy_indice=non_sys_indice.get_indice("bob-1")# Retrieves an indice object from the indice bob-1# Alternative way of getting the Indice Objectmy_indice_2=ElasticSearchIndice("bob-2",es_conn)print("Indice{}has the following properties".format(my_indice.name))print("- Status:{}".format(my_indice.status))print("- Health:{}".format(my_indice.health))print("- Number of documents:{}".format(my_indice.docs))print("- Size:{}".format(my_indice.size))doc_data={"message":"I am a test message","user":"test user","purpose":"TESTING...DUUU"}# Creating Documentsdoc=my_indice.create_doc(doc_data)# this creates a do and lets elasticsearch generate the iddoc=my_indice.create_doc(doc_data,name="document-1234")# this creates a document that you generate the id for# Deleting Documentsmy_indice.delete_doc("document-1234")Immediate future TODO ListAdd document search to indice objectAdd templatesDocument documents object