Package amplee :: Package indexer
[show private | hide private]
[frames | no frames]

Package amplee.indexer

Really simple indexing implementation for amplee

I assume something bigger such as Lucene would be much more efficient.

For example:
>>> import time
>>> from amplee.indexer import *
>>> ind = Indexer()
>>> container = ShelveContainer('/tmp/cache.p')
>>> pi = PublishedIndex('pi', container=container, granularity=DateIndex.month)
>>> container2 = ShelveContainer('/tmp/cache2.p')
>>> ai = AuthorIndex('ai', container=container2)
>>> ind.register(pi)
>>> ind.register(ai)

# With the indexer daemon >>> ind.start_daemon(interval=1.0) >>> try: >>> index(member) >>> time.sleep(3) >>> finally: >>> ind.stop_daemon()

# Or without >>> ind.process(member)
>>> from datetime import datetime
>>> start = datetime(2006, 10, 8, 14, 00, 12)
>>> end = datetime(2008, 10, 8, 16, 00, 12)
>>> r0 = pi.between(start, end)
>>> print r0 
>>> r1 = ai.lookup('Jon Doe')
>>> print r1

# You can even concatenate both set of results into one >>> print r0 & r1

# Or substract (assuming r2) >>> print r0 & r2 - r1

Once you get a result dictionnary you can do something like this:
>>> collection_name, member_id = r.pop()
>>> c0 = service.get_collection(collection_name)
>>> member = c0.get_member(member_id)
Or to get a list of member instances.
>>> items = ind.to_dict(r)
>>> for collection_name in items:
c = service.get_collection(collection_name)
        members = c.reload_members_from_list(items[collection_name])

Classes
AtomIDIndexer  
AuthorIndex  
BaseIndex  
CategoryIndex  
DateIndex  
Indexer  
KeywordIndex  
MemcacheContainer  
MemoryContainer Dummy memory container based on the dictionnary.
PublishedIndex  
ShelveContainer  
UpdatedIndex  

Function Summary
  index(member)
Add the member to queue of elements to be indexed.

Function Details

index(member)

Add the member to queue of elements to be indexed.

The ``member`` is an instance of any of the member classes provided by amplee.

Note that qe-queuing will be asynchronized and thus this function will return before the member is actually indexed.

Generated by Epydoc 2.1 on Thu Jul 19 15:32:16 2007 http://epydoc.sf.net