From 858107a929e826681629f34b384926488aeb1cd1 Mon Sep 17 00:00:00 2001 From: yvesf Date: Mon, 22 Nov 2010 19:54:33 +0100 Subject: scroll preview page to page-match; sort matches by pagenumber --- web.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'web.py') diff --git a/web.py b/web.py index 0fc770d..a8dcbca 100644 --- a/web.py +++ b/web.py @@ -6,7 +6,6 @@ from StringIO import StringIO from whoosh.index import open_dir from whoosh.qparser import QueryParser import whoosh.searching as searching -import whoosh.fields as fields import whoosh.analysis as analysis import whoosh.highlight as highlight import whoosh.query as query @@ -95,8 +94,8 @@ def excerpt(docnum, term): if fieldname == "content" ] excerpt = highlight.highlight(result.get("content"), terms, - analysis.FancyAnalyzer(), - highlight.SentenceFragmenter(), + analysis.StandardAnalyzer(), + highlight.ContextFragmenter(terms, maxchars=400, charsbefore=40, charsafter=40), #highlight.SentenceFragmenter(maxchars=500), MyHtmlFormatter()) yield json.dumps( { 'pagenumber':result.get("pagenumber"), @@ -125,7 +124,7 @@ def do_search(skip=0,term=None): searcher = index_book.searcher() query = QueryParser("content").parse(term) facets = searching.Facets.from_field(searcher, "path") - results = searcher.search(query, limit=None) + results = searcher.search(query, limit=None, sortedby="pagenumber") categories = facets.categorize(results) searcher.close() -- cgit v1.2.1