1. Matt Chaput
  2. whoosh
  3. Issues
Issue #383 new

AttributeError when attempting to invoke Searcher.correct_query() on a query with a range.

Elliot Shank
created an issue

Complete example program:

#!/usr/bin/env python

import os
import os.path

from whoosh.index   import create_in
from whoosh.fields  import Schema
from whoosh.qparser import QueryParser

index_path = r'/tmp/test-range-correction'
if not os.path.exists(index_path):

schema = Schema()
index = create_in(index_path, schema)

parser = QueryParser(None, schema)
query_string = r'[a to z]'
query = parser.parse(query_string)
searcher = index.searcher()
corrected_query = searcher.correct_query(query, query_string)

Running this results in

Traceback (most recent call last):
    File "./test-range-correction", line 21, in <module>
        corrected_query = searcher.correct_query(query, query_string)
    File "<path>/lib/python3.3/site-packages/Whoosh-2.6.0-py3.3.egg/whoosh/searching.py", line 918, in correct_query
        for token in q.all_tokens():
    File "<path>/lib/python3.3/site-packages/Whoosh-2.6.0-py3.3.egg/whoosh/query/qcore.py", line 419, in all_tokens
        for token in self.tokens(boost):
    File "<path>/lib/python3.3/site-packages/Whoosh-2.6.0-py3.3.egg/whoosh/query/terms.py", line 165, in tokens
        btexts = [self.text]
AttributeError: 'TermRange' object has no attribute 'text'