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

Package indexer

source code

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)

# Querying >>> 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 [hide private]
  MemoryContainer
Dummy memory container based on the dictionnary.
  ShelveContainer
  MemcacheContainer
  CyclicTimer
A thread timer that runs untl it is explicitely stopped.
  Indexer
  BaseIndex
  DateIndex
  PublishedIndex
  UpdatedIndex
  EditedIndex
  AuthorIndex
  CategoryIndex
  KeywordIndex
  AtomIDIndexer
Functions [hide private]
 
index(member)
Add the member to queue of elements to be indexed.
source code
Variables [hide private]
  __doc__ = """Really simple indexing implementation for amp...
  _queue = Queue()
Function Details [hide private]

index(member)

source code 

Add the member to queue of elements to be indexed.

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

Variables Details [hide private]

__doc__

Value:
"""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 *
...