Closed poljar closed 4 years ago
Would be great that search
function allows a list of collectors. From the API point of view its better to map Tantivy collectors to Python objects and send them on a list or map each collector to a string so the API would be:
searcher().search(query, 'top')
searcher().search(query, ['top', 'count'])
searcher().search(query, ['top', 'count', { 'person': ['john']}])
or:
top_collector = tantivy.TopDocs(10)
count_collector = tantivy.Count()
facet_collector = tantivy.FacetDocs('/person/john', '/person/bob')
index.searcher().search(query, (top_collector, count_collector, facet_collector))
Yeah or even drop the idea of a collector here, and just add a bunch of options describing what we want.
e.g
We most likely won't handle custom collectors in python anyway, so we might as well have a specialized API that is more straightforward to understand.
This has been put on hold since a wrongfully configured schema causes Tantivy to panic. Python users will most likely perceive crashes as bugs, until we can convert the panic into a Python exception this will unlikely be added.
@poljar Agreed. This is a bad behavior for rust too. Let's fix that.
This is now possible, relevant commit 094f8974ea100fbb1eca7aad4078cd650410e51f.
Tantivy supports ordering the search results from a TopCollector by a field. This used to be done with the
TopDocsByField
collector and a patch was written to partially utilize this https://github.com/matrix-org/tantivy/commit/85b8d0c7826092b11d81aa1f0b45e5512305f69c.The latest Tantivy release dropped
TopDocsByfield
and uses the generic Collector trait instead.This sadly makes it impossible to modify the mentioned patch since it uses the
Any
type and down-casting and down-casting trait objects is impossible:There are tricks to work around of this but support for this would need to land in Tantivy.