diff options
Diffstat (limited to 'web.py')
-rw-r--r-- | web.py | 7 |
1 files changed, 3 insertions, 4 deletions
@@ -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() |