Skip to main content

Python Wrapper for elasticsearch

Project description

elasticpy
===========

Python wrapper for the elasticsearch indexing utility.

Author: Luke Campbell <luke.s.campbell@gmail.com>

HOWTO
-----

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

* 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](http://www.elasticsearch.org/guide/reference/query-dsl/) 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
> {'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](http://www.elasticsearch.org/guide/reference/query-dsl/) just like query.

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


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

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.

Project details


Download files

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

Source Distribution

elasticpy-0.7.tar.gz (15.6 kB view details)

Uploaded Source

File details

Details for the file elasticpy-0.7.tar.gz.

File metadata

  • Download URL: elasticpy-0.7.tar.gz
  • Upload date:
  • Size: 15.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for elasticpy-0.7.tar.gz
Algorithm Hash digest
SHA256 8e27e3ae6191ba47070e132fd0bebda70c1b649d146b37c89e05907fb1616bc3
MD5 0b602637b8e0c39513f9e842915224f3
BLAKE2b-256 245721625987c17b72d5677ee64c26718366b6f80fb75210b314dc73ec801a5e

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page