Skip to content
This repository has been archived by the owner on Sep 23, 2022. It is now read-only.

Commit

Permalink
Just text changes, no code changes
Browse files Browse the repository at this point in the history
  • Loading branch information
eriky committed Apr 22, 2013
1 parent 603d77a commit 293a2eb
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 218 deletions.
2 changes: 1 addition & 1 deletion README.rst
Expand Up @@ -4,7 +4,7 @@ ESClient
ESClient is a Python library that uses the ElasticSearch REST API. It is meant
to be lightweight and be *close to the actual REST API* in terms of usage.

With ESClient comes two script that are installed in your /usr/local/bin:
With ESClient comes two scripts that are installed in your /usr/local/bin:

* esdump -- Use this script to dump one or more indexes to a file (or stdout)

Expand Down
4 changes: 2 additions & 2 deletions bin/esimport
Expand Up @@ -8,8 +8,8 @@ import argparse
import sys
import json

parser = argparse.ArgumentParser(description="Import a dump from esdump, optionally overriding the index name and document type." +
" This tool will auto-detect the file type (plain, gz, bzip2) based on the file extension." +
parser = argparse.ArgumentParser(description="Import a dump from esdump, optionally overriding the index name and/or document type." +
" This tool will auto-detect the file type (plain, gz, bzip2) based on the file extension.\n" +
" !! Please note that you have to create the appropriate mappings yourself !!")

parser.add_argument('--url', '-u', required=True, help="The full URL to the ElasticSearch server, including port")
Expand Down
215 changes: 0 additions & 215 deletions doc/documentation.html
@@ -1,215 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.4: http://docutils.sourceforge.net/" />
<title>ESClient usage</title>
<style type="text/css">

/*
:Authors: Ian Bicking, Michael Foord
:Contact: fuzzyman@voidspace.org.uk
:Date: 2005/08/26
:Version: 0.1.0
:Copyright: This stylesheet has been placed in the public domain.

Stylesheet for Docutils.
Based on ``blue_box.css`` by Ian Bicking
and ``html4css1.css`` revision 1.46.
*/

@import url(http://rst2a.com/static/styles/html/default.css);

body {
font-family: Arial, sans-serif;
}

em, i {
/* Typically serif fonts have much nicer italics */
font-family: Times New Roman, Times, serif;
}

a.target {
color: blue;
}

a.target {
color: blue;
}

a.toc-backref {
text-decoration: none;
color: black;
}

a.toc-backref:hover {
background-color: inherit;
}

a:hover {
background-color: #cccccc;
}

div.attention, div.caution, div.danger, div.error, div.hint,
div.important, div.note, div.tip, div.warning {
background-color: #cccccc;
padding: 3px;
width: 80%;
}

div.admonition p.admonition-title, div.hint p.admonition-title,
div.important p.admonition-title, div.note p.admonition-title,
div.tip p.admonition-title {
text-align: center;
background-color: #999999;
display: block;
margin: 0;
}

div.attention p.admonition-title, div.caution p.admonition-title,
div.danger p.admonition-title, div.error p.admonition-title,
div.warning p.admonition-title {
color: #cc0000;
font-family: sans-serif;
text-align: center;
background-color: #999999;
display: block;
margin: 0;
}

h1, h2, h3, h4, h5, h6 {
font-family: Helvetica, Arial, sans-serif;
border: thin solid black;
/* This makes the borders rounded on Mozilla, which pleases me */
-moz-border-radius: 8px;
padding: 4px;
}

h1 {
background-color: #444499;
color: #ffffff;
border: medium solid black;
}

h1 a.toc-backref, h2 a.toc-backref {
color: #ffffff;
}

h2 {
background-color: #666666;
color: #ffffff;
border: medium solid black;
}

h3, h4, h5, h6 {
background-color: #cccccc;
color: #000000;
}

h3 a.toc-backref, h4 a.toc-backref, h5 a.toc-backref,
h6 a.toc-backref {
color: #000000;
}

h1.title {
text-align: center;
background-color: #444499;
color: #eeeeee;
border: thick solid black;
-moz-border-radius: 20px;
}

table.footnote {
padding-left: 0.5ex;
}

table.citation {
padding-left: 0.5ex
}

pre.literal-block, pre.doctest-block {
border: thin black solid;
padding: 5px;
}

.image img { border-style : solid;
border-width : 2px;
}

h1 tt, h2 tt, h3 tt, h4 tt, h5 tt, h6 tt {
font-size: 100%;
}

code, tt {
color: #000066;
}

</style>
</head>
<body>
<div class="document" id="esclient-usage">
<h1 class="title">ESClient usage</h1>
<div class="section">
<h1><a id="start-or-install-elasticsearch" name="start-or-install-elasticsearch">Start or install ElasticSearch</a></h1>
<p>First of all, you have to get ElasticSearch running. If you don't have it
installed, please head over to the <a class="reference" href="http://www.elasticsearch.org/">ElasticSearch</a> site and download it.
Once unpacked, you can simply run ElasticSearch in the foreground with:</p>
<p><tt class="docutils literal"><span class="pre">bin/elasticsearch</span> <span class="pre">-f</span></tt></p>
<p>See.. it's easy to get a test system up and running.</p>
</div>
<div class="section">
<h1><a id="installing-esclient" name="installing-esclient">Installing ESClient</a></h1>
<p>Installing ESClient is easy too. You can use pip or easy_install, whichever
you prefer.</p>
<p>E.g. with easy_install you'd enter:</p>
<p><tt class="docutils literal"><span class="pre">sudo</span> <span class="pre">easy_install</span> <span class="pre">esclient</span></tt></p>
<p>Alternatively you may also download ESClient from its <a class="reference" href="https://github.com/eriky/ESClient">Github</a> site. After
unpacking, you can install ESClient with:</p>
<p><tt class="docutils literal"><span class="pre">sudo</span> <span class="pre">python</span> <span class="pre">setup.py</span> <span class="pre">install</span></tt></p>
</div>
<div class="section">
<h1><a id="an-interactive-python-session" name="an-interactive-python-session">An interactive Python session</a></h1>
<p>To demonstrate ESClient, we will walk through an interactive Python session
and show the ESClient API by example.</p>
<p>First, fire up python:</p>
<p><tt class="docutils literal"><span class="pre">$</span> <span class="pre">python</span></tt></p>
<p>At the prompt, enter:</p>
<p><tt class="docutils literal"><span class="pre">&gt;&gt;&gt;</span> <span class="pre">import</span> <span class="pre">esclient</span></tt></p>
<p>You can read the documentation that comes with the esclient code by entering:</p>
<p><tt class="docutils literal"><span class="pre">&gt;&gt;&gt;</span> <span class="pre">help(esclient)</span></tt></p>
<p>This should be basic stuff for the average Python programmer though. So let
us really dive into ESClient now.
You first need to create an ESClient object, like so:</p>
<p><tt class="docutils literal"><span class="pre">&gt;&gt;&gt;</span> <span class="pre">es</span> <span class="pre">=</span> <span class="pre">esclient.ESClient()`</span></tt></p>
<p>ESClient will by default use localhost as the hostname in combination with
the default port 9200. You can supply an alternative location for ElasticSearch
like so:</p>
<p><tt class="docutils literal"><span class="pre">&gt;&gt;&gt;</span> <span class="pre">es</span> <span class="pre">=</span> <span class="pre">esclient.ESClient('http://&lt;hostname&gt;:&lt;port&gt;')</span></tt></p>
<p>Now that we have an ESClient instance, we can start doing some interesting
stuff. First of all let's request the status of the ElasticSearch cluster:</p>
<p><tt class="docutils literal"><span class="pre">&gt;&gt;&gt;es.status()</span></tt></p>
<pre class="literal-block">
{u'indices': {}, u'ok': True, u'_shards': {u'successful': 0, u'failed': 0, u'total': 0}}
</pre>
<p>Well, great. Now let's create an index. Open the create index API page at
<a class="reference" href="http://www.elasticsearch.org/guide/reference/api/admin-indices-create-index.html">http://www.elasticsearch.org/guide/reference/api/admin-indices-create-index.html</a>
and read that page. Now we are going to map this knowledge to ESClient.</p>
<p>First of all we need to create a request body that allows us the specify
the number of shards and number of replicas we want for our index:</p>
<pre class="literal-block">
body= {
&quot;settings&quot; : {
&quot;index&quot; : {
&quot;number_of_shards&quot; : 1,
&quot;number_of_replicas&quot; : 0
}
}
}
</pre>
<p>With this, we can create an index easily:</p>
<p><tt class="docutils literal"><span class="pre">&gt;&gt;&gt;</span> <span class="pre">es.create_index(&quot;contacts&quot;,</span> <span class="pre">body=body)</span></tt></p>
</div>
</div>
</body>
</html>

0 comments on commit 293a2eb

Please sign in to comment.