Skip to main content
elasticpy
===========
_"ElasticSearch for the rest of us"_

Python wrapper for the elasticsearch indexing utility.

Author: [Luke Campbell](http://lukecampbell.github.com/) [<luke.s.campbell@gmail.com>](mailto:luke.s.campbell@gmail.com)

About
-----
The goal of this module is to provide an intuitive interface between Python APIs and the ElasticSearch API. Connections are provided through the `requests` library so the connections are inherently thread safe and pooled.

Writing complex queries in JSON can be tedius and time consuming if you need to constantly reference the Query DSL guide, so we've wrapped most of the operations in classes with methods corresponding to the parameters of the operation. For example:

sorts = ElasticSort()
sorts.sort('name',order='asc')
sorts.sort('_score')
----
[{"name": {"order": "asc"}}, {"_score": {"order": "asc"}}]

Queries, Filters, Sorts, Maps and Facets are wrapped in convenience classes. Searching is done through the ElasticSearch class.

HOWTO
-----

To begin using elasticpy start by importing.

import elasticpy as ep

To interface with the elasticsearch server use the ElasticSearch object.

search = ep.ElasticSearch() # Defaults to localhost:9200

To form a query use the ElasticQuery wrapper objects.

query = ep.ElasticQuery().term('users':'luke')

# and then pass it to the search object

search.search_advanced('twitter','feeds',query)

> {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}

USAGE
-----
* Queries - `ElasticQuery`

query = ElasticQuery()

* Term Searches

query.term(name='luke')

* Text Searches

query.text('message', 'this is a test')

* Text Phrases

query.text_phrase('message', 'this is a test')

* Fuzzy

query.fuzzy('name','luke',boost=1.0)

* Fuzzy Like This

query.fuzzy_like_this('luke',fields='_all')

* **Match All**

query.match_all()

* Wildcard

query.wildcard('name','lu*')

* Filters - `ElasticFilter`

filters = ElasticFilter()

* And

filters.and_filter(query)

* Bool

filters.bool_filter(must=query1, must_not=query2, should=query3)

* Geo

* Geo Distance

filters.geo_distance('location',{'lat':30,'lon':30}, '20km')

* Geo Bounding Box

filters.geo_bounding_box('location', {'lat':60, 'lon':60}, {'lat':30, 'lon':30})

* Match All

filters.match_all()

* Range

filters.numeric_range('price',8.0, 9.9)



Copying
-----------

**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

[http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Metadata

Release files for elasticpy 0.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for elasticpy 0.9
File Size Uploaded Provenance Actions
elasticpy-0.9.tar.gz 16.6 kB Without provenance Details for elasticpy-0.9.tar.gz

Release files / elasticpy-0.9.tar.gz

Download URL elasticpy-0.9.tar.gz
Size 16.6 kB
Tags Source
SHA-256 checksum
How to use checksums
da7759d4d5571c5a3f449018b178a76af48d78ab493893b22760ef0e798bd40f
BLAKE2b-256 checksum
How to use checksums
a2cf9c0d6491c8520efb501124a49b0e73e037cc7933e3a0a384693d8a2225c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for elasticpy 0.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page