mirror of
https://github.com/Hopiu/xapian-haystack.git
synced 2026-04-17 21:31:00 +00:00
Potential fix for count being out of sync on large datasets
This commit is contained in:
parent
fb0f883cb3
commit
e65cecdb55
1 changed files with 15 additions and 2 deletions
|
|
@ -424,7 +424,7 @@ class SearchBackend(BaseSearchBackend):
|
|||
|
||||
return {
|
||||
'results': results,
|
||||
'hits': matches.get_matches_estimated(),
|
||||
'hits': self._get_hit_count(database, enquire),
|
||||
'facets': facets_dict,
|
||||
'spelling_suggestion': spelling_suggestion,
|
||||
}
|
||||
|
|
@ -514,7 +514,7 @@ class SearchBackend(BaseSearchBackend):
|
|||
|
||||
return {
|
||||
'results': results,
|
||||
'hits': matches.get_matches_estimated(),
|
||||
'hits': self._get_hit_count(database, enquire),
|
||||
'facets': {
|
||||
'fields': {},
|
||||
'dates': {},
|
||||
|
|
@ -832,6 +832,19 @@ class SearchBackend(BaseSearchBackend):
|
|||
database.reopen()
|
||||
return document.get_data()
|
||||
|
||||
def _get_hit_count(self, database, enquire):
|
||||
"""
|
||||
Given a database and enquire instance, returns the estimated number
|
||||
of matches.
|
||||
|
||||
Required arguments:
|
||||
`database` -- The database to be queried
|
||||
`enquire` -- The enquire instance
|
||||
"""
|
||||
return self._get_enquire_mset(
|
||||
database, enquire, 0, database.get_doccount()
|
||||
).get_matches_estimated()
|
||||
|
||||
def _value_column(self, field):
|
||||
"""
|
||||
Private method that returns the column value slot in the database
|
||||
|
|
|
|||
Loading…
Reference in a new issue