1. Matt Chaput
  2. whoosh
  3. Issues
Issue #302 resolved

Search with filter raises exception: AttributeError: 'TermsCollector' object has no attribute 'offset'

Rishi Sharma
created an issue

Hi Matt: First I must say you have put together a beautiful product. One issue that I am having is regarding the filter on search. When the filter arg is passed a value (in my case a python set), I get the following error:

Traceback (most recent call last):

  File "./views.py", line 65, in query_index
    results = s.search_page(q, pagenum=pg, pagelen=10, terms=True, filter=working_set)
  File "/home/rishi/Projects/ngeluta/local/lib/python2.7/site-packages/whoosh/searching.py", line 561, in search_page
    results = self.search(query, limit=pagenum * pagelen, **kwargs)
  File "/home/rishi/Projects/ngeluta/local/lib/python2.7/site-packages/whoosh/searching.py", line 762, in search
    self.search_with_collector(q, c)
  File "/home/rishi/Projects/ngeluta/local/lib/python2.7/site-packages/whoosh/searching.py", line 804, in search_with_collector
    collector.collect_matches()
  File "/home/rishi/Projects/ngeluta/local/lib/python2.7/site-packages/whoosh/collectors.py", line 598, in collect_matches
    global_docnum = child.offset + sub_docnum
AttributeError: 'TermsCollector' object has no attribute 'offset'

Here is the context of my issue:

def query_index(phrase, pg=1, working_set=set([1,2,3])):
    ix = open_dir("indexdir", indexname="jobs")
    qp = QueryParser('position_text', schema=ix.schema)
    q = qp.parse(unicode(phrase))

    with ix.searcher() as s:
        s.set_caching_policy(save=False)
        results = s.search_page(q, pagenum=pg, pagelen=10, terms=True, filter=working_set)

Comments (3)

  1. Log in to comment