Issue #302 resolved

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

Rishi Sharma avatarRishi 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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.