def render_prevset_url(self, context, data): words = WORDS_RGX.findall( normalizeText(unicode(context.arg('words'), 'utf-8'))) offset = int(context.arg('offset', 0)) if offset: offset -= 15 return 'search?words=%s&offset=%s' % ('+'.join(words), offset)
def findDocuments(self, query): """Find all indexed documents matching the query""" words = WORDS_RGX.findall(normalizeText(query)) self._updateQueryStatistics(words) try: cursor = self._cnx.cursor() return Document.selectContaining(cursor, words) finally: cursor.close()
def findDocuments(self, query): """Find all indexed documents matching the query""" # TODO: order results using document_scores information words = WORDS_RGX.findall(normalizeText(unicode(query.words))) self._updateQueryStatistics(words) try: cursor = self._cnx.cursor() return Document.selectContaining(cursor, words, query.filetype, query.offset, self.searchInPrivate) finally: cursor.close()
def notifyDownload(self, db_document_id, query): words = WORDS_RGX.findall(normalizeText(query)) try: try: cursor = self._cnx.cursor() doc = Document.selectWhere(cursor, db_document_id=db_document_id)[0] finally: cursor.close() self._updateDownloadStatistics(doc, words) return doc.url except IndexError: return ''
def render_nextset_url(self, context, data): words = WORDS_RGX.findall(normalizeText(unicode(context.arg('words'), 'utf-8'))) offset = int(context.arg('offset', 0)) + 15 return 'search?words=%s&offset=%s' % ('+'.join(words), offset)