Permalink
Browse files

Move sample programs, write new intro

  • Loading branch information...
1 parent c98596b commit 30f45de4f137cfbf18021805415a2aa8db3d5f1b @willkg willkg committed Apr 23, 2013
Showing with 69 additions and 23 deletions.
  1. +59 −10 docs/index.rst
  2. +3 −6 docs/{quickstart.rst → sampleprogram.rst}
  3. +0 −7 docs/sampleprogram1.rst
  4. +7 −0 docs/sampleprogramfacets.rst
View
@@ -4,11 +4,6 @@
ElasticUtils
==============
-ElasticUtils is a Python library that gives you a chainable search API
-for `ElasticSearch <http://elasticsearch.org/>`_ as well as some other
-tools to make it easier to integrate ElasticSearch into your
-application.
-
:Version: |release|
:Code: https://github.com/mozilla/elasticutils
:License: BSD; see LICENSE file
@@ -17,6 +12,63 @@ application.
:IRC: #elasticutils on irc.mozilla.org
+ElasticUtils is a Python library that gives you a chainable search API
+for `ElasticSearch <http://elasticsearch.org/>`_ as well as some other
+tools to make it easier to integrate ElasticSearch into your
+application.
+
+So what's it like? Let's do a couple basic things:
+
+Create an instance of :py:class:`elasticutils.S` and tell it which
+index and doctype to look at.
+
+>>> from elasticutils import S, F
+>>> s = S().indexes('blog-index').doctypes('blog-entry')
+
+Print the count of everything in that index with that type:
+
+>>> print s.count()
+4
+
+Show titles of all blog entries with "elasticutils" in the title:
+
+>>> s = s.query(title__match='elasticutils')
+>>> [result['title'] for result in s]
+[u'ElasticUtils v0.4 released!', u'elasticutils status -- May 18th, 2012',
+u'ElasticUtils sprint at PyCon US 2013']
+
+Use properties rather than keys:
+
+>>> [result.title for result in s]
+[u'ElasticUtils v0.4 released!', u'elasticutils status -- May 18th, 2012',
+u'ElasticUtils sprint at PyCon US 2013']
+
+Filter out entries related to PyCon:
+
+>>> s = s.filter(~F(tag='pycon'))
+>>> [result['title'] for result in s]
+[u'ElasticUtils v0.4 released!', u'elasticutils status -- May 18th, 2012']
+
+Show only the top result:
+
+>>> s = s[:1]
+>>> [result['title'] for result in s]
+[u'ElasticUtils v0.4 released!']
+
+That's the gist of it!
+
+
+Project
+=======
+
+.. toctree::
+ :maxdepth: 1
+
+ changelog
+ theory
+ resources
+
+
.. _users-guide:
User's Guide
@@ -25,15 +77,11 @@ User's Guide
.. toctree::
:maxdepth: 1
- changelog
installation
- quickstart
- theory
queries
es
debugging
api
- resources
Using ElasticUtils with Django
@@ -66,7 +114,8 @@ Sample programs
.. toctree::
:maxdepth: 1
- sampleprogram1
+ sampleprogram
+ sampleprogramfacets
Indices and tables
@@ -1,9 +1,6 @@
-============
- Quickstart
-============
-
-Sample program
-==============
+======================
+ Basic sample program
+======================
Here's a short script that gives you the gist of how to use
ElasticUtils:
@@ -1,7 +0,0 @@
-====================
- Sample with facets
-====================
-
-.. literalinclude:: samples/sample_facets.py
- :language: python
- :linenos:
@@ -0,0 +1,7 @@
+=============================
+ Sample program using facets
+=============================
+
+.. literalinclude:: samples/sample_facets.py
+ :language: python
+ :linenos:

0 comments on commit 30f45de

Please sign in to comment.