Skip to content

Refactor docsearch to use facets and not emulate a queryset #5235

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

Closed
ericholscher opened this issue Feb 5, 2019 · 0 comments · Fixed by #7114
Closed

Refactor docsearch to use facets and not emulate a queryset #5235

ericholscher opened this issue Feb 5, 2019 · 0 comments · Fixed by #7114
Labels
Bug A bug Needed: design decision A core team decision is required

Comments

@ericholscher
Copy link
Member

ericholscher commented Feb 5, 2019

Currently the way our Docsearch works abuses the fact that ElasticSearch DSL Search objects look like querysets:

https://github.com/rtfd/readthedocs.org/blob/2bf6e9943c4177d11e125fd077a07f7168fce044/readthedocs/search/api.py#L16-L28

This causes a few different issues, which we should address by refactoring it:

  • There is currently no way to return facets with this approach. It treats each Hit as an object, but the facets are returned at the top-level. In particular, the serializer doesn't even get access to the facet, because it's only passed each Hit object.
  • Currently the count returned in by the docsearch REST API is wrong. I believe this is because of the way we're filtering the results, but I think it might be happening after pagination.

We might be able to work around these limitations, but I think the proper solution is to build the REST API using a custom approach, and pass the data in from Search directly, instead of trying to depend on the fact that Search's look like Queryset's.

@ericholscher ericholscher added the Needed: design decision A core team decision is required label Feb 5, 2019
@ericholscher ericholscher added this to the Search improvements milestone Feb 5, 2019
@humitos humitos added the Bug A bug label Feb 6, 2019
stsewd added a commit that referenced this issue May 21, 2020
The recommended way of using pagination over
a custom object is to manage the class ourselves.
I tried rely on most of the defaults of the DRF's pagination class.

Closes #5235
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug Needed: design decision A core team decision is required
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants