You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my project I'm trying to create a query aggregator using multiple indexes (take a query, run it on multiple searchers, aggregate the results).
It would be really useful to have a way to access a score from an index in a random-access way (ex. given a document id, a query and a searcher, what's the resulting score?).
The solution I came up with having not much experience with the code-base is this:
fromwhoosh.matchingimportIntersectionMatcher, ListMatcherfromwhoosh.queryimportQueryfromwhoosh.searchingimportSearcherdefrandom_access_score(query: Query, searcher: Searcher, docid: int) ->tuple[int, float]:
forsubsearcher, offsetinsearcher.leaf_searchers():
m=query.matcher(subsearcher, context=searcher.context())
m=IntersectionMatcher(ListMatcher([docid], [0]), m)
ifm.is_active():
returnm.id(), m.score()
# necessary in case of no hit for docidreturn-1, 0
Is this correct? is there a more efficient way to do this? (I expect this to iterate over all of the posting lists, right?).
Thank you in advance!
The text was updated successfully, but these errors were encountered:
cclauss
pushed a commit
to cclauss/whoosh-1
that referenced
this issue
Jan 4, 2024
Hello, thanks for this library!
In my project I'm trying to create a query aggregator using multiple indexes (take a query, run it on multiple searchers, aggregate the results).
It would be really useful to have a way to access a score from an index in a random-access way (ex. given a document id, a query and a searcher, what's the resulting score?).
The solution I came up with having not much experience with the code-base is this:
Is this correct? is there a more efficient way to do this? (I expect this to iterate over all of the posting lists, right?).
Thank you in advance!
The text was updated successfully, but these errors were encountered: