Skip to main content

Python Wrapper for elasticsearch

Project description


Python wrapper for the elasticsearch indexing utility.

Author: Luke Campbell <>


To begin using elasticpy start by importing.
import elasticpy

To interface with the elasticsearch server use the ElasticSearch object.

search = elasticpy.ElasticSearch()

To form a query use the ElasticQuery objects.

query = elasticpy.ElasticQuery().term('users':'luke')
# and then pass it to the search object
> {u'_shards': {u'failed': 0, u'successful': 5, u'total': 5},
u'hits': {u'hits': [{u'_id': u'1',
u'_index': u'twitter',
u'_score': 0.30685282,
u'_source': {u'content': u'This is an example.', u'user': u'luke'},
u'_type': u'feeds'}],
u'max_score': 0.30685282,
u'total': 1},
u'timed_out': False,
u'took': 3}


* Simple Searching, queries ElasticSearch using GET on a url based query.

search_simple(index, type, key, search_term)

* Advanced Searching, queries to ElasticSearch using a GET method and passing a JSON object containing the detailed query parameters, typically assembled by using an ElasticQuery object.

search_advanced(index, type, query)

* Searching an index, the entails searching the entire index and all the types within.

search_index_simple(index, key, search_term)
search_index_advanced(index, query)

* Queries closely match the query types specified by [QueryDSL]( used in ElasticSearch. They are wrapped in python methods to make them creation of the objects easier to manage than JSON strings.

query = elasticpy.ElasticQuery().query_string(query='any')
> {'query_string': {'allow_leading_wildcard': True,
'analyze_wildcard': None,
'auto_generate_phase_queries': False,
'boost': 1.0,
'default_field': '_all',
'default_operator': 'OR',
'enable_position_increments': True,
'fuzzy_min_sim': 0.5,
'fuzzy_prefix_length': 0,
'lowercase_expanded_terms': True,
'phrase_slop': 0,
'query': 'any'}}

* Filters also closely match the [QueryDSL]( just like query.

filter = elasticpy.ElasticFilter().term('user','luke').range('age',21,26)
> {'range': {'age': {'from': 18,
'include_lower': True,
'include_upper': False,
'to': 25}},
'term': {'user': 'luke'}}


elasticpy - Python Wrapper for ElasticSearch

Copyright 2012 UC Regents

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and
limitations under the License.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for elasticpy, version 0.8
Filename, size File type Python version Upload date Hashes
Filename, size elasticpy-0.8.tar.gz (15.6 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page