Search results are not sorted

Issue #78 duplicate
Nikolaus Rath
created an issue

{{{

!python

!/usr/bin/env python

import tempfile
import atexit
import shutil
import whoosh.index
import whoosh.fields
from datetime import datetime
from whoosh.fields import Schema
from whoosh.query import Every, Not

tempdir = tempfile.mkdtemp()
atexit.register(lambda : shutil.rmtree(tempdir))

schema = Schema(title=whoosh.fields.ID(stored=True, unique=True),
expiration_date=whoosh.fields.DATETIME)
ix = whoosh.index.create_in(tempdir, schema)
writer = ix.writer()

writer.add_document(title=u'No expiration', expiration_date=None)
writer.add_document(title=u'Expires 2010-06-12',
expiration_date=datetime(2010, 6, 12))
writer.add_document(title=u'Expires 2010-05-12',
expiration_date=datetime(2010, 5, 12))

writer.commit()

searcher = ix.searcher()

results = searcher.search(Not(Every(u'expiration_date')))

results = searcher.search(Every(u'expiration_date'),
sortedby='expiration_date',
reverse=False)

print whoosh.versionstring()
for doc in results:
print doc['title']
}}}

yields

{{{
1.3.3
Expires 2010-06-12
Expires 2010-05-12
}}}

no matter if reverse=True or reverse=False.

Comments (1)

  1. Log in to comment