Skip to main content

autocomplete with redis

Project description

autocompletion with redis based on:

redis-completion is capable of storing a large number of phrases and quickly searching them for matches. Rich data can be stored and retrieved, helping you avoid trips to the database when retrieving search results.

check out the documentation for more info.

usage

If you just want to store really simple things, like strings:

engine = RedisEngine()
titles = ['python programming', 'programming c', 'unit testing python',
          'testing software', 'software design']
map(engine.store, titles)

>>> engine.search('pyt')
['python programming', 'unit testing python']

>>> engine.search('test')
['testing software', 'unit testing python']

If you want to store more complex data, like blog entries:

Entry.create(title='an entry about python', published=True)
Entry.create(title='all about redis', published=True)
Entry.create(title='using redis with python', published=False)

for entry in Entry.select():
    engine.store_json(entry.id, entry.title, {
        'published': entry.published,
        'title': entry.title,
        'url': entry.get_absolute_url(),
    })

>>> engine.search_json('pytho')
[{'published': True, 'title': 'an entry about python', 'url': '/blog/1/'},
 {'published': False, 'title': 'using redis with python', 'url': '/blog/3/'}]

# just published entries, please
>>> engine.search_json('redis', filters=[lambda i: i['published'] == True])
[{u'published': True, u'title': u'all about redis', u'url': u'/blog/2/'}]

installing

Install with pip:

pip install redis-completion

Install via git:

git clone https://github.com/coleifer/redis-completion.git
cd redis-completion
python setup.py install

schema

http://redis-completion.readthedocs.org/en/latest/_images/schema.jpg

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

redis-completion-0.5.0.tar.gz (40.9 kB view details)

Uploaded Source

File details

Details for the file redis-completion-0.5.0.tar.gz.

File metadata

File hashes

Hashes for redis-completion-0.5.0.tar.gz
Algorithm Hash digest
SHA256 0c52c2cac8b85323272296905dc04bf03acf56ec34e554727a19667257ab062d
MD5 18188d12bd80ab3b6c71ca387710b078
BLAKE2b-256 cf5d2ffa383eeec56cda068e3db7abfa5681130aecebbae9a843ed3b156ec4f9

See more details on using hashes here.

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