Package: python-whoosh
Version: 2.3.2-2

i386, kernel3.2.0-4-686-pae

I've found a problem with queries with the boolean NOT.

Try this example:

#!/usr/bin/python

from whoosh.index import create_in,open_dir
from whoosh.fields import *
from whoosh.qparser import QueryParser
import os


class Co:
    def __init__(self):
        home_content = './CONTENT'
        self.schema = Schema(content=TEXT(stored=False),ud=ID(stored=True))
        if not os.path.exists(home_content):
            os.mkdir(home_content)
            self.ic = create_in(home_content,self.schema)
        else:
            self.ic=open_dir(home_content)
        self.writer = self.ic.writer()
        self.writer.add_document(content = u"pippo",ud = u"1")
        self.writer.add_document(content = u"pluto",ud = u"2")
        self.writer.commit()

    def search(self,pattern,tipo):
        with self.ic.searcher() as searcher:
            qp=QueryParser(tipo,self.ic.schema)
            query=qp.parse(pattern)
            results = searcher.search(query,limit=None)
            for result in results:
                print result

c=Co()
c.search(u'NOT pippo',u'content')


Try to run this script more times: it gives wrong results and after 8 times 
gives the follow error:
Traceback (most recent call last):
  File "./content_NOT.py", line 34, in <module>
    c.search(u'NOT pippo',u'content')
  File "./content_NOT.py", line 30, in search
    print result
  File "/usr/lib/python2.7/dist-packages/whoosh/searching.py", line 1784, in 
__repr__
    return "<%s %r>" % (self.__class__.__name__, self.fields())
  File "/usr/lib/python2.7/dist-packages/whoosh/searching.py", line 1670, in 
fields
    self._fields = self.searcher.stored_fields(self.docnum)
  File "/usr/lib/python2.7/dist-packages/whoosh/reading.py", line 722, in 
stored_fields
    return self.readers[segmentnum].stored_fields(segmentdoc)
  File "/usr/lib/python2.7/dist-packages/whoosh/filedb/filereading.py", line 
156, in stored_fields
    in iteritems(self.storedfields[docnum])
  File "/usr/lib/python2.7/dist-packages/whoosh/filedb/filetables.py", line 
792, in __getitem__
    % (num, self.length))
IndexError: Tried to get document 4, file has 4


Walter


--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to