- Timestamp:
- 27/11/07 01:09:26 (3 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pyndexter/branches/simplification/pyndexter/indexers/_hyperestraier.py
r465 r466 78 78 79 79 def index(self, document): 80 uri = unicode(document.uri)80 key = unicode(document.key) 81 81 hdoc = hyperestraier.Document() 82 82 for k, v in document.iteritems(): 83 83 hdoc.add_attr(u'@' + k, v) 84 hdoc.add_attr(u'@uri', uri)84 hdoc.add_attr(u'@uri', key) 85 85 for line in document.texts: 86 86 hdoc.add_text(line) 87 87 if not self.db.put_doc(hdoc): 88 raise errors.IndexerError('Failed to index %s' % document. uri)88 raise errors.IndexerError('Failed to index %s' % document.key) 89 89 90 def discard(self, uri): 91 uri = unicode(uri) 92 if not self.db.out_doc_by_uri(uri): 93 raise errors.DocumentNotFound(uri) 90 def discard(self, key): 91 key = unicode(key) 92 try: 93 self.db.out_doc_by_uri(key) 94 except hyperestraier.HyperestraierError, e: 95 raise errors.DocumentNotFound(key) 94 96 95 def fetch(self, uri):96 uri = unicode(uri)97 doc = self.db.get_doc_by_uri( uri)97 def fetch(self, key): 98 key = unicode(key) 99 doc = self.db.get_doc_by_uri(key) 98 100 if not doc: 99 raise errors.DocumentNotFound( uri)101 raise errors.DocumentNotFound(key) 100 102 attributes = self._translate_attributes(doc) 101 return Document( uri, texts=doc.dtexts, quality=0.99,103 return Document(key, texts=doc.dtexts, quality=0.99, 102 104 attributes=attributes) 103 105 … … 152 154 # Internal methods 153 155 def _translate(self, doc): 154 return Hit( uri=doc.uri, document=self.indexer.fetch,156 return Hit(key=doc.uri, document=self.indexer.fetch, 155 157 attributes=self.indexer._translate_attributes(doc))
