I see some strange behavior when using a search filter. Hopefully these two snippets show what I mean. I'm using Whoosh 2.7.4.
(1.) Snippet:
#!python
with search_iJP815._index.searcher() as search:
res = search.search(_11, limit=None)
print(len(res))
print(res.scored_length())
print(list(res))
So the first snippet works as I expect. However, when I introduce a filter, all results suddenly disappear.
(2.) Snippet:
#!python
allow = Term("kind", "metabolites")
with search_iJP815._index.searcher() as search:
res = search.search(_11, filter=allow, limit=None)
print(len(res))
print(res.scored_length())
print(res.filtered_count)
print(list(res))
(2.) Output:
0
0
16
[]
Please note that in the first output there were plenty of hits with kind == "metabolites". So what am I doing wrong? The schema is the following, by the way.
#!python
import whoosh.fields as wfields
class SearchSchema(wfields.SchemaClass):
"""Describe the schema for indexing cobra objects."""
id = wfields.ID(stored=True, unique=True, field_boost=2.0)
name = wfields.NGRAM(maxsize=5)
kind = wfields.STORED
Original report by Moritz E. Beber (Bitbucket: midnighter, GitHub: midnighter).
I see some strange behavior when using a search filter. Hopefully these two snippets show what I mean. I'm using Whoosh
2.7.4
.(1.) Snippet:
(1.) Output:
So the first snippet works as I expect. However, when I introduce a filter, all results suddenly disappear.
(2.) Snippet:
(2.) Output:
Please note that in the first output there were plenty of hits with
kind == "metabolites"
. So what am I doing wrong? The schema is the following, by the way.