1. Matt Chaput
  2. whoosh
  3. Pull requests

Pull requests

#52 Merged
Repository
clonezone
Branch
correct_query-highlight
Repository
mchaput
Branch
default

Change Formatter.format_fragment() to not assume that tokens have startchars.

Author
  1. Elliot Shank
Reviewers
Description

I've got a field with spelling correction. If I then query_parser.remove_plugin_class(BoostPlugin) and attempt searcher.correct_query(query, "foo^3"), where the spelling correction has a suggestion for "foo", I get a stack trace like

  File "query.py", line 130, in query
    corrected_query = searcher.correct_query(query, query_string)
  File "<install path>/lib/python3.3/site-packages/Whoosh-2.6.0-py3.3.egg/whoosh/searching.py", line 928, in correct_query
    return sqc.correct_query(q, qstring)
  File "<install path>/lib/python3.3/site-packages/Whoosh-2.6.0-py3.3.egg/whoosh/spelling.py", line 334, in correct_query
    return Correction(q, qstring, corrected_q, corrected_tokens)
  File "<install path>/lib/python3.3/site-packages/Whoosh-2.6.0-py3.3.egg/whoosh/spelling.py", line 219, in __init__
    self.string = self.format_string(highlight.NullFormatter())
  File "<install path>/lib/python3.3/site-packages/Whoosh-2.6.0-py3.3.egg/whoosh/spelling.py", line 242, in format_string
    return formatter.format_fragment(fragment, replace=True)
  File "<install path>/lib/python3.3/site-packages/Whoosh-2.6.0-py3.3.egg/whoosh/highlight.py", line 603, in format_fragment
    if t.startchar < index:
TypeError: unorderable types: NoneType() < int()

This change to highlight.py prevents this exception.

  • Learn about pull requests

Comments (0)