Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TimeLimitCollector breaks filter of underlying FilterCollector #567

Open
richardebeling opened this issue Sep 24, 2020 · 0 comments
Open

Comments

@richardebeling
Copy link

richardebeling commented Sep 24, 2020

As far as I understand the documentation, a TimeLimitCollector can be used to simply wrap any other collector in order to add a time-out feature. It should not affect the results in any way.

However, in a code base I'm working on, adding a TimeLimitCollector breaks the filtering of an underlying FilterCollector

This happens on the current PyPI release (2.7.4) as well as the current master (5421f1a).

Minimal example to reproduce:

#!/usr/bin/env python3
import os

from whoosh.fields import Schema, TEXT, ID
from whoosh.filedb.filestore import FileStorage
from whoosh.query import Term
from whoosh.qparser import QueryParser
from whoosh.collectors import TimeLimitCollector

if not os.path.exists("test_index"):
    os.makedirs("test_index")

schema = Schema(id=ID(stored=True), text=TEXT(stored=True))
storage = FileStorage("test_index")
ix = storage.create_index(schema)
writer = ix.writer()
writer.add_document(text=u"test", id="1")
writer.commit()

query_parser = QueryParser("text", schema)
query = query_parser.parse("test")
id_term = Term("id", "0")

with ix.searcher() as searcher:
    collector = searcher.collector(limit=10, filter=id_term)

    # Add this line and the assertion will fail
    # collector = TimeLimitCollector(collector, timelimit=5.0)

    searcher.search_with_collector(query, collector)

    print(collector.results())
    assert(len(collector.results()) == 0)

Did I misunderstand something or is this a bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant