Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix count value of docsearch REST api #5926

Merged
merged 1 commit into from
Jul 15, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions readthedocs/search/faceted_search.py
Original file line number Diff line number Diff line change
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