Skip to content

Commit

Permalink
Merge pull request #5926 from dojutsu-user/results-total-hack
Browse files Browse the repository at this point in the history
Fix count value of docsearch REST api
  • Loading branch information
ericholscher committed Jul 15, 2019
2 parents e12f70d + b1105e8 commit 7e112c1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions readthedocs/search/faceted_search.py
Expand Up @@ -99,6 +99,16 @@ class PageSearchBase(RTDFacetedSearch):
fields = ['title^10', 'headers^5', 'content']
operators = ['and', 'or']

def count(self):
"""Overriding ``count`` method to return the count of the results after post_filter."""
s = self.build_search()

# setting size=0 so that no results are returned,
# we are only interested in the total count
s = s.extra(size=0)
s = s.execute()
return s.hits.total


class DomainSearchBase(RTDFacetedSearch):
facets = {
Expand Down

0 comments on commit 7e112c1

Please sign in to comment.