Package grassyknoll :: Package backend :: Package lucene :: Module Smarts :: Class SmartStorage
[hide private]

Class SmartStorage

source code


A wrapper around a lucene index with a smarter API

Instance Methods [hide private]
 
__init__(self, index_dir=None, create=False)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
index_dir(self) source code
 
close(self)
close all resources
source code
 
searcher(self)
return fresh IndexSearcher
source code
 
reader(self)
@type IndexReader
source code
 
optimize(self)
Optimize the index.
source code
 
configureWriter(self, writer)
configure an IndexWriter.
source code
HitsWrapper of SmartHits
search(self, query)
search the index
source code
 
insert(self, doc)
insert a document
source code
 
delete(self, name_or_term, value=None)
delete documents from lucene index matching Term
source code
 
getAllTerms(self, field, include_counts=True)
yield all terms for a given field
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Static Methods [hide private]
 
configureUpdatingWriter(writer)
configure an IndexWriter for updates.
source code
 
configureBulkWriter(writer)
configure an IndexWriter for bulk loading.
source code
Class Variables [hide private]
  logger = logging.getLogger("SmartStorage")
Instance Variables [hide private]
lucene.Analyzer analyzer
a Lucene analyzer
FSDirectory directory
the lucene Directory
bool enable_bulk_writes
if true, configure writer optimized for bulk loading.
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, index_dir=None, create=False)
(Constructor)

source code 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Parameters:
  • create (bool) - create the index if it doesn't exist
Overrides: object.__init__

index_dir(self)

source code 
Decorators:
  • @property

searcher(self)

source code 
return fresh IndexSearcher
Decorators:
  • @property

reader(self)

source code 
@type IndexReader
Decorators:
  • @property

configureWriter(self, writer)

source code 
configure an IndexWriter.
Parameters:
  • writer (IndexWriter) - the new IndexWriter

configureUpdatingWriter(writer)
Static Method

source code 
configure an IndexWriter for updates.
Parameters:
  • writer (IndexWriter) - the new IndexWriter

configureBulkWriter(writer)
Static Method

source code 
configure an IndexWriter for bulk loading.
Parameters:
  • writer (IndexWriter) - the new IndexWriter

search(self, query)

source code 
search the index
Parameters:
  • query (String or lucene.Query) - a Lucene query
Returns: HitsWrapper of SmartHits

insert(self, doc)

source code 
insert a document
Parameters:
  • doc (SmartDoc) - the document to insert

delete(self, name_or_term, value=None)

source code 
delete documents from lucene index matching Term
Parameters:
  • name_or_term (string or Term) - field name or Term to delete
  • value (unicode or None) - field value, or None if a passing a Term

getAllTerms(self, field, include_counts=True)

source code 
yield all terms for a given field
Parameters:
  • field (String) - name of the field
  • include_counts (Boolean) - should value frequencies be included
Returns:
if include_counts is True, tuples of (term, count). If false, just list of terms

Instance Variable Details [hide private]

enable_bulk_writes

if true, configure writer optimized for bulk loading. If false, configure for updates. Defaults to False.
Type:
bool