Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

Elasticsearch client with Django support.

Project description

rubber
======

rubber is a Python client for Elasticsearch.

Its main features are:
- rubber is easy to use
- rubber integrates nicely with Django

Dependencies
============

rubber needs the 'requests' Python package.

Installation
============

pip install rubber

Usage
=====

Basic usage
----------

import rubber

client = rubber.ElasticSearch('articles', 'article')

# Searching
for hit in client.search({'query':{'term':{'user':'kimshy'}}}).hits:
print hit.source.user

# Mapping
client.mapping.put(my_mapping) # my_mapping is a dict object
client.mapping.delete()
mapping = client.mapping.get()

Django integration
------------------

import rubber
from django.db import models

class Article(models.Model):
elasticsearch = rubber.ElasticSearch()
title = models.CharField(max_length=255)
content = models.TextField()

# Searching
response = Article.elasticsearch.search(query) # query is a dict

# Mapping
Article.elasticsearch.mapping.put(mapping) # mapping is a dict

# Auto save
a = Article(title='I love ES')
a.save() # Automatically sent to elasticsearch
a.delete() # Automatically removed from elasticsearch

Configuration
-------------

### Disabling the auto-save behavior for Django models

import rubber
from django.db import models

class Article(models.Model):
elasticsearch = rubber.ElasticSearch(auto_index=False)
title = models.CharField(max_length=255)
content = models.TextField()


### Configuring index name and document type for a Django model

import rubber
from django.db import models

class Article(models.Model):
elasticsearch = rubber.ElasticSearch(index_name='custom_index', type='custom_type')


### Saving to multiple indices

import rubber
from django.db import models

class Article(models.Model):
index1 = rubber.ElasticSearch(index_name='index1', type='type1')
index2 = rubber.ElasticSearch(index_name='index2', type='type2')

Project details


Release history Release notifications

History Node

0.1.8

History Node

0.1.7

History Node

0.1.6

History Node

0.1.5

History Node

0.1.4

History Node

0.1.3

This version
History Node

0.1.2

History Node

0.1.1

History Node

0.1

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
rubber-0.1.2.tar.gz (6.3 kB) Copy SHA256 hash SHA256 Source None Aug 2, 2012

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page