diff options
author | yvesf <yvesf-git@xapek.org> | 2010-11-22 19:54:33 +0100 |
---|---|---|
committer | yvesf <yvesf-git@xapek.org> | 2010-11-22 19:54:33 +0100 |
commit | 858107a929e826681629f34b384926488aeb1cd1 (patch) | |
tree | b6cb1b1497c2af8bb939ca8640caf5143616975e /web.py | |
parent | 37212428d94d95b14618a2e69610fa77c99ae123 (diff) | |
download | booksearch-858107a929e826681629f34b384926488aeb1cd1.tar.gz booksearch-858107a929e826681629f34b384926488aeb1cd1.zip |
scroll preview page to page-match; sort matches by pagenumber
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() |