{ "info": { "author": "Kunihiko Kido", "author_email": "kunihiko.kido@me.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "elasticsearch-fabric\n====================\n\nThis package provides a unified command line interface to Elasticsearch\nin Fabric.\n\nInstallation\n------------\n\nThe current release, published on PyPI, can be installed using the\nfollowing command:\n\n.. code:: sh\n\n $ pip install elasticsearch-fabric\n\nConfiguration\n-------------\n\nTasks\n~~~~~\n\nIf you plan to use the built-in tasks, include the module in your\nfabfile module (e.g. fabfile.py). Most likely you might want to assign\nan alias for the task namespace:\n\n.. code:: python\n\n from esfabric import tasks as es\n\nEnvironment\n~~~~~~~~~~~\n\n- ``elasticsearch_clients``: Customize elasticsearch client\n configurations.\n- ``elasticsearch_alias``: Default Elasticsearch client alias in\n elasticsearch\\_clients. default \"default\"\n- ``elasticsearch_dest_alias``: Reindex dest Elasticsearch client alias\n in elasticsearch\\_clients. default elasticsearch\\_alias\n\nExamples\n^^^^^^^^\n\n.. code:: python\n\n # cat fabfile.py\n from fabric.api import env\n from elasticsearch import Elasticsearch\n from esfabric import tasks as es\n\n\n env.elasticsearch_clients = {\n \"default\": Elasticsearch(**{\n \"host\": \"localhost\",\n \"port\": 9200,\n \"send_get_body_as\": \"POST\"\n }),\n \"example\": Elasticsearch(**{\n \"host\": \"search.example.org\",\n \"port\": 443,\n \"send_get_body_as\": \"POST\",\n \"use_ssl\": True,\n \"verify_certs\": True\n })\n }\n\nElasticsearch with Shield\n~~~~~~~~~~~~~~~~~~~~~~~~~\n\nYou can configure the client to use basic authentication:\n\n.. code:: python\n\n # cat fabfile.py\n from fabric.api import env\n from elasticsearch import Elasticsearch\n from esfabric import tasks as es\n\n\n env.elasticsearch_clients = {\n \"default\": Elasticsearch(**{\n \"host\": \"localhost\",\n \"port\": 9200,\n \"send_get_body_as\": \"POST\",\n \"http_auth\": ('user', 'secret')\n })\n }\n\nRunning on AWS with IAM\n~~~~~~~~~~~~~~~~~~~~~~~\n\n.. code:: python\n\n # cat fabfile.py\n from fabric.api import env\n from elasticsearch import Elasticsearch\n from elasticsearch import RequestsHttpConnection\n from requests_aws4auth import AWS4Auth\n from esfabric import tasks as es\n\n awsauth = AWS4Auth(YOUR_ACCESS_KEY, YOUR_SECRET_KEY, REGION, 'es')\n\n env.elasticsearch_clients = {\n \"default\": Elasticsearch(**{\n \"host\": \"YOURHOST.us-east-1.es.amazonaws.com\",\n \"port\": 443,\n \"send_get_body_as\": \"POST\",\n \"http_auth\": awsauth,\n \"use_ssl\": True,\n \"verify_certs\": True,\n \"connection_class\": RequestsHttpConnection\n })\n }\n\nChecking the setup\n------------------\n\nFor checking if everything is set up properly, you can run the included\ntask *info*. For example, running\n\n.. code:: sh\n\n $ fab es.info\n\nyou can show a similar result:\n\n.. code:: sh\n\n {\n \"cluster_name\": \"elasticsearch\",\n \"tagline\": \"You Know, for Search\",\n \"version\": {\n \"lucene_version\": \"5.5.0\",\n \"build_hash\": \"218bdf10790eef486ff2c41a3df5cfa32dadcfde\",\n \"number\": \"2.3.3\",\n \"build_timestamp\": \"2016-05-17T15:40:04Z\",\n \"build_snapshot\": false\n },\n \"name\": \"Ares\"\n }\n\n\n Done.\n\nExample use\n-----------\n\nYou can do this for example with the following command:\n\n.. code:: sh\n\n # -------------------------------------------------------------\n # by Default connect to localhost:9200\n $ fab es.info\n {\n \"cluster_name\": \"elasticsearch\",\n \"tagline\": \"You Know, for Search\",\n \"version\": {\n \"lucene_version\": \"5.5.0\",\n \"build_hash\": \"218bdf10790eef486ff2c41a3df5cfa32dadcfde\",\n \"number\": \"2.3.3\",\n \"build_timestamp\": \"2016-05-17T15:40:04Z\",\n \"build_snapshot\": false\n },\n \"name\": \"Ares\"\n }\n\n\n Done.\n\n # -------------------------------------------------------------\n # index a document\n #\n # $ cat doc.json\n # {\n # \"title\": \"Hello Elasticsearch\",\n # \"description\": \"elasticsearch fabric test\"\n # }\n $ cat doc.json | fab es.index:index=blog,doc_type=posts,id=1\n {\n \"_type\": \"posts\",\n \"created\": true,\n \"_shards\": {\n \"successful\": 1,\n \"failed\": 0,\n \"total\": 2\n },\n \"_version\": 1,\n \"_index\": \"blog\",\n \"_id\": \"1\"\n }\n\n\n Done.\n\n # -------------------------------------------------------------\n # get the document.\n $ fab es.get:index=blog,doc_type=posts,id=1\n {\n \"_type\": \"posts\",\n \"_source\": {\n \"description\": \"elasticsearch fabric test\",\n \"title\": \"Hello Elasticsearch\"\n },\n \"_index\": \"blog\",\n \"_version\": 1,\n \"found\": true,\n \"_id\": \"1\"\n }\n\n\n Done.\n\n # -------------------------------------------------------------\n # simple query search.\n $ fab es.search:q=\"title:hello\"\n {\n \"hits\": {\n \"hits\": [\n {\n \"_score\": 0.19178301,\n \"_type\": \"posts\",\n \"_id\": \"1\",\n \"_source\": {\n \"description\": \"elasticsearch fabric test\",\n \"title\": \"Hello Elasticsearch\"\n },\n \"_index\": \"blog\"\n }\n ],\n \"total\": 1,\n \"max_score\": 0.19178301\n },\n \"_shards\": {\n \"successful\": 26,\n \"failed\": 0,\n \"total\": 26\n },\n \"took\": 4,\n \"timed_out\": false\n }\n\n Done.\n\n # -------------------------------------------------------------\n # request body search.\n #\n # $ cat query.json\n # {\n # \"query\": {\n # \"match\": {\n # \"title\": \"hello\"\n # }\n # }\n # }\n $ cat query.json | fab es.search\n {\n \"hits\": {\n \"hits\": [\n {\n \"_score\": 0.19178301,\n \"_type\": \"posts\",\n \"_id\": \"1\",\n \"_source\": {\n \"description\": \"elasticsearch fabric test\",\n \"title\": \"Hello Elasticsearch\"\n },\n \"_index\": \"blog\"\n }\n ],\n \"total\": 1,\n \"max_score\": 0.19178301\n },\n \"_shards\": {\n \"successful\": 26,\n \"failed\": 0,\n \"total\": 26\n },\n \"took\": 8,\n \"timed_out\": false\n }\n\n\n Done.\n\n # -------------------------------------------------------------\n # change number of replicas\n #\n # cat indices\n $ fab es.cat.indices\n health status index pri rep docs.count docs.deleted store.size pri.store.size\n yellow open blog 5 1 1 0 3.9kb 3.9kb\n # change number of replicas\n $ fab es.helpers.change_replicas:index=blog,number_of_replicas=0\n {\n \"acknowledged\": true\n }\n # cat indices\n $ fab es.cat.indices:v=1\n health status index pri rep docs.count docs.deleted store.size pri.store.size\n green open blog 5 0 1 0 3.9kb 3.9kb\n\n\n # -------------------------------------------------------------\n # reindex blog to blog2\n $ fab es.helpers.reindex:source_index=blog,dest_index=blog2\n {\n \"dest\": {\n \"index\": \"blog2\",\n \"host\": \"http://localhost:9200\"\n },\n \"source\": {\n \"index\": \"blog\",\n \"host\": \"http://localhost:9200\"\n },\n \"errors\": 0,\n \"success\": 1\n }\n\n\n Done.\n # cat indices\n $ fab es.cat.indices:v=1\n health status index pri rep docs.count docs.deleted store.size pri.store.size\n yellow open blog2 5 1 1 0 3.7kb 3.7kb\n green open blog 5 0 1 0 3.9kb 3.9kb\n\nClient selection\n----------------\n\n.. code:: python\n\n # fabfile.py\n from esfabric import tasks as es\n from esfabric.tasks import client_selection\n\n env.elasticsearch_clients = {\n \"client1\": Elasticsearch(**{\n ...\n }),\n \"client2\": Elasticsearch(**{\n ...\n })\n }\n\n.. code:: sh\n\n $ fab c:client2 es.info\n\n``c`` is client\\_selection alias\n\nLogging\n-------\n\nyou can enable the elasticsearch.trace logger and have it log a shell\ntranscript of your session using curl:\n\n.. code:: python\n\n # fabfile.py\n import logging\n tracer = logging.getLogger('elasticsearch.trace')\n tracer.setLevel(logging.DEBUG)\n tracer.addHandler(logging.FileHandler('/tmp/elasticsearch-py.sh'))\n\nCustom Task\n-----------\n\n.. code:: python\n\n from esfabric import tasks as es\n from fabric.api import execute, task\n\n\n @task\n def change_replicas(number_of_replicas=1):\n execute(es.cat.indices, v=1)\n execute(es.helpers.change_replicas, number_of_replicas=number_of_replicas)\n execute(es.cat.indices, v=1)\n\nrun task:\n\n.. code:: sh\n\n $ fab change_replicas:10\n\nAvailable commands\n------------------\n\nThe following command will show a list of avaliable commands.\n\n.. code:: sh\n\n $ fab -l\n\n- Available commands\n- es.bulk\n- es.c\n- es.clear\\_scroll\n- es.client\\_selection\n- es.count\n- es.count\\_percolate\n- es.create\n- es.delete\n- es.delete\\_by\\_query\n- es.delete\\_script\n- es.delete\\_template\n- es.exists\n- es.explain\n- es.field\\_stats\n- es.get\n- es.get\\_script\n- es.get\\_source\n- es.get\\_template\n- es.index\n- es.info\n- es.mget\n- es.mpercolate\n- es.msearch\n- es.msearch\\_template\n- es.mtermvectors\n- es.percolate\n- es.ping\n- es.put\\_script\n- es.put\\_template\n- es.reindex\n- es.reindex\\_rethrottle\n- es.render\\_search\\_template\n- es.scroll\n- es.search\n- es.search\\_shards\n- es.search\\_template\n- es.suggest\n- es.termvectors\n- es.update\n- es.update\\_by\\_query\n- es.cat.aliases\n- es.cat.allocation\n- es.cat.count\n- es.cat.fielddata\n- es.cat.health\n- es.cat.indices\n- es.cat.master\n- es.cat.nodeattrs\n- es.cat.nodes\n- es.cat.pending\\_tasks\n- es.cat.plugins\n- es.cat.recovery\n- es.cat.repositories\n- es.cat.segments\n- es.cat.shards\n- es.cat.snapshots\n- es.cat.thread\\_pool\n- es.cluster.allocation\\_explain\n- es.cluster.get\\_settings\n- es.cluster.health\n- es.cluster.pending\\_tasks\n- es.cluster.put\\_settings\n- es.cluster.reroute\n- es.cluster.state\n- es.cluster.stats\n- es.helpers.bulk\n- es.helpers.change\\_replicas\n- es.helpers.reindex\n- es.helpers.scan\n- es.indices.analyze\n- es.indices.clear\\_cache\n- es.indices.close\n- es.indices.create\n- es.indices.delete\n- es.indices.delete\\_alias\n- es.indices.delete\\_template\n- es.indices.exists\n- es.indices.exists\\_alias\n- es.indices.exists\\_template\n- es.indices.exists\\_type\n- es.indices.flush\n- es.indices.flush\\_synced\n- es.indices.forcemerge\n- es.indices.get\n- es.indices.get\\_alias\n- es.indices.get\\_field\\_mapping\n- es.indices.get\\_mapping\n- es.indices.get\\_settings\n- es.indices.get\\_template\n- es.indices.get\\_upgrade\n- es.indices.open\n- es.indices.put\\_alias\n- es.indices.put\\_mapping\n- es.indices.put\\_settings\n- es.indices.put\\_template\n- es.indices.recovery\n- es.indices.refresh\n- es.indices.rollover\n- es.indices.segments\n- es.indices.shard\\_stores\n- es.indices.shrink\n- es.indices.stats\n- es.indices.update\\_aliases\n- es.indices.upgrade\n- es.indices.validate\\_query\n- es.nodes.hot\\_threads\n- es.nodes.info\n- es.nodes.stats\n- es.snapshot.create\n- es.snapshot.create\\_repository\n- es.snapshot.delete\n- es.snapshot.delete\\_repository\n- es.snapshot.get\n- es.snapshot.get\\_repository\n- es.snapshot.restore\n- es.snapshot.status\n- es.snapshot.verify\\_repository", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/KunihikoKido/elasticsearch-fabric", "keywords": "elasticsearch,fabric", "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "elasticsearch-fabric", "package_url": "https://pypi.org/project/elasticsearch-fabric/", "platform": "OS Independent", "project_url": "https://pypi.org/project/elasticsearch-fabric/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/KunihikoKido/elasticsearch-fabric" }, "release_url": "https://pypi.org/project/elasticsearch-fabric/0.1.5/", "requires_dist": null, "requires_python": null, "summary": "This package provides a unified command line interface to Elasticsearch in Fabric.", "version": "0.1.5" }, "last_serial": 2534102, "releases": { "0.1.0": [], "0.1.1": [ { "comment_text": "", "digests": { "md5": "348c3ce6288880c513ae8d161b02ceb8", "sha256": "5034e775d31cdf2b1217bf3d0b375bb03271e8a855941e86f36b0e4d1b759c45" }, "downloads": -1, "filename": "elasticsearch-fabric-0.1.1.tar.gz", "has_sig": false, "md5_digest": "348c3ce6288880c513ae8d161b02ceb8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10977, "upload_time": "2016-12-08T03:59:48", "url": "https://files.pythonhosted.org/packages/5b/da/71c89a783d5caa06cbeebd99672cb321559728bd9891834c999f835e2cb6/elasticsearch-fabric-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "8ccc7c56d04fb00096631d0fd37167ce", "sha256": "734bdae342201abeb0597fe3937a08de7ac0824a4f483054b7d6e910ce718677" }, "downloads": -1, "filename": "elasticsearch-fabric-0.1.2.tar.gz", "has_sig": false, "md5_digest": "8ccc7c56d04fb00096631d0fd37167ce", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11003, "upload_time": "2016-12-08T07:23:34", "url": "https://files.pythonhosted.org/packages/96/f5/4c36cfa84afa5b628dfe9a3460bded75521c3aee429cb966e168d28e6d92/elasticsearch-fabric-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "8564b0a1474d863e42b36aa6230c0d26", "sha256": "03c447a39a7b0280d2dba7052417449ce44a5c01e5a20907924843c8415a937a" }, "downloads": -1, "filename": "elasticsearch-fabric-0.1.3.tar.gz", "has_sig": false, "md5_digest": "8564b0a1474d863e42b36aa6230c0d26", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11293, "upload_time": "2016-12-08T08:55:28", "url": "https://files.pythonhosted.org/packages/3f/d6/5499e18d9b099fadeba01e507bad93bd92312134578343b3954245b2d848/elasticsearch-fabric-0.1.3.tar.gz" } ], "0.1.4": [ { "comment_text": "", "digests": { "md5": "79bd1e288df7a4ed5e580ea3ed0fdbf2", "sha256": "571ea1e50aad326a3aa277698720ef85d8269f5e02de949ea020dcc574bc2548" }, "downloads": -1, "filename": "elasticsearch-fabric-0.1.4.tar.gz", "has_sig": false, "md5_digest": "79bd1e288df7a4ed5e580ea3ed0fdbf2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13104, "upload_time": "2016-12-15T06:17:11", "url": "https://files.pythonhosted.org/packages/3c/99/e65ab904cc202baccba17d53daa926f55e6b2dc2ff7697ecf4304f9947c0/elasticsearch-fabric-0.1.4.tar.gz" } ], "0.1.5": [ { "comment_text": "", "digests": { "md5": "ad535befdb4c0151b93b2724bffbb091", "sha256": "99bc498653dd252907c45e29c11d234c95946a46d85d83ccb00860a5e0a24996" }, "downloads": -1, "filename": "elasticsearch-fabric-0.1.5.tar.gz", "has_sig": false, "md5_digest": "ad535befdb4c0151b93b2724bffbb091", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15145, "upload_time": "2016-12-22T03:32:07", "url": "https://files.pythonhosted.org/packages/fe/cd/d559b8404774bd6cfe712839473309fb03aa3f1a849ad50f5cc7887bc9c1/elasticsearch-fabric-0.1.5.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "ad535befdb4c0151b93b2724bffbb091", "sha256": "99bc498653dd252907c45e29c11d234c95946a46d85d83ccb00860a5e0a24996" }, "downloads": -1, "filename": "elasticsearch-fabric-0.1.5.tar.gz", "has_sig": false, "md5_digest": "ad535befdb4c0151b93b2724bffbb091", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15145, "upload_time": "2016-12-22T03:32:07", "url": "https://files.pythonhosted.org/packages/fe/cd/d559b8404774bd6cfe712839473309fb03aa3f1a849ad50f5cc7887bc9c1/elasticsearch-fabric-0.1.5.tar.gz" } ] }