Closed jdcaballerov closed 4 years ago
@rgaudin Can you clarify How's the API use of get_matches_estimated()
to close this feature ??
I can already use the iterator from Cython for both search and suggestions (File.h
)
The first number is the result of get_matches_estimated()
def file_search(self, query, start=0, end=10):
cdef unique_ptr[zim.Search] search = self.c_file.search(query.encode('UTF-8'),start, end)
cdef zim.search_iterator it = dereference(search).begin()
print(dereference(search).get_matches_estimated())
while it != dereference(search).end():
yield it.get_url().decode('UTF-8')
preincrement(it)
UTF-8 not decoded here but already fixed.
Thanks for this.
file_search()
and not search()
? Do you intend to keep both versions?Otherwise, we'd need better names like get_search_results_count()
and get_suggestions_results_count()
I have file_search
since I haven't deleted the old search
version waiting for your approval. The other works from C++ sending string vectors of 10, this one runs in Cython using the libzim search object directly.
If you agree then I'll only keep this and delete the C++ search code from the wrapper and add the counts as separate.
Ah ok I see. that's unfortunate. I didn't realized you hardcoded that. We should definitely be able to set those. But we'd need the number of results (from
get_matches_estimated()
) as well. How do you plan to address that?