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

Search: API V3 #9625

Merged
merged 40 commits into from
Nov 25, 2022
Merged

Search: API V3 #9625

merged 40 commits into from
Nov 25, 2022

Conversation

stsewd
Copy link
Member

@stsewd stsewd commented Sep 27, 2022

Implementation of #9533

Fixes #9573

This is on top of #9624

At first, I started to find a way to share most of the code with API v2, but the code resulted hard to follow,
so I just did a clean start for the new API (well, almost, there are still a lot of things that are being re-used).

  • The new syntax can be used in the global search
  • The project search now redirects to the global search with the current project set in the query.
  • Some facets have been removed to just support the project/language facets.
  • The global search now defaults to type=file.
  • You can still search projects.
  • The project facet isn't used directly, but only to aggregate results in the dashboard.
  • The documentation was re-organized into a new directory instead of just one page.
  • The advanced search guide was deleted, and their contents are now part of the documentation itself.

📚 Documentation previews 📚

We were generating the context of the serializer
from outside, but we can do this from
the serializer itself,
this way we don't have to duplicate this logic.
@stsewd stsewd changed the base branch from main to refactor-search-serializer-context September 27, 2022 00:33
@stsewd stsewd mentioned this pull request Sep 27, 2022
@stsewd stsewd force-pushed the refactor-search-serializer-context branch from e84b905 to e145700 Compare September 29, 2022 00:26
@stsewd
Copy link
Member Author

stsewd commented Oct 4, 2022

This should be ready, but we should first merge #9624, so I can fix the merge conflicts :/

Base automatically changed from refactor-search-serializer-context to main October 6, 2022 20:23
@ericholscher
Copy link
Member

@stsewd This feels close. You mentioned some width issues w/ the search box, do you have a link to a good screenshot of that?

@stsewd
Copy link
Member Author

stsewd commented Nov 7, 2022

@ericholscher sorry, I thought I've attached screenshots in the PR description, looks like I didn't.

Screenshot 2022-11-07 at 16-49-18 Search project subproject project test-builds test Read the Docs
Screenshot 2022-11-07 at 16-48-48 Search project subproject test Read the Docs
Screenshot 2022-11-07 at 16-51-15 Search project subproject project test-builds search something more big Read the Docs

Basically, the text hides behind the "Search" button, and it also takes a lot of space that would be welcome when searching more than one project. We should probably just replace it with an icon and have the search bar not overlap with the button (not sure how this implemented in the new templates)

@ericholscher
Copy link
Member

Yea, 👍 on either hiding the search box, or just moving it down to a new line.

@agjohnson agjohnson linked an issue Nov 8, 2022 that may be closed by this pull request
Copy link
Member

@humitos humitos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I started doing a review but I noticed that it will take more time than I thought. It seems to be a big project. I'll come back to it with more time and focus.

Comment on lines +22 to +23
project = serializers.SerializerMethodField()
version = serializers.SerializerMethodField()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not creating a proper serializer for each of them instead of methods?

Example of this from APIv3

urls = VersionURLsSerializer(source='*')

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only one we can do this for is for the version, for the project we need to call get_project_alias to get the alias. The objects these serializers deal with are ES result objects, not RTD objects, we don't have that field in the ES object.

@ericholscher ericholscher linked an issue Nov 9, 2022 that may be closed by this pull request
2 tasks
@stsewd
Copy link
Member Author

stsewd commented Nov 14, 2022

@ericholscher I'm trying to fix the search bar, but looks like we are using it in other places as well (the same structure/css classes).

Current state

Screenshot 2022-11-14 at 13-45-41 Versions Read the Docs
Screenshot 2022-11-14 at 13-45-27 Home Read the Docs
Screenshot from 2022-11-14 13-46-01

My small fix

Looks like the problem is with the width being hardcoded (width: 513px;)

.wide-search-bar input[type="text"] { border-top-left-radius: 3px; border-bottom-left-radius: 3px; -moz-border-radius-topleft: 3px; -moz-border-radius-bottomleft: 3px; -webkit-border-top-left-radius: 3px; -webkit-border-bottom-left-radius: 3px; width: 513px; }

So I tried to fix it setting the width to width: 100%;

Screenshot from 2022-11-14 13-41-02
Screenshot from 2022-11-14 13-41-26
Screenshot from 2022-11-14 13-41-48

The overlap is reduced, but now all forms have that small overlap.

Moving the button to a new line may require some more CSS...

Screenshot 2022-11-14 at 13-57-02 Search project test-builds Read the Docs

New templates

The new templates won't/don't have this issue

Screenshot 2022-11-14 at 14-01-53 Search project test-builds - Read the Docs

If my small fix is enough, let me know. But I'm not sure if it's worth investing more time in that with the new templates coming 🤔

@ericholscher
Copy link
Member

@stsewd I don't think we need to invest much time in this. It seems fine as is, as well. It's not broken, so definitely don't invest much time here.

@ericholscher
Copy link
Member

@stsewd I'm pretty happy with where this PR is. Is there any backwards incompatible changes required here, or can we roll it out and roll it back if needed?

@stsewd
Copy link
Member Author

stsewd commented Nov 17, 2022

@ericholscher

  • The doc structure was changed (redirects are needed in place, cc @benjaoming in case any of this collides with the work of moving our docs to diataxis)
  • most of the facets are removed (dashboard search)
  • Old project search links will redirect to the global search

One small detail that you may have an opinion on #9533 (comment).

What's next?

  • Use api v3 in our embedded js search
  • Use api v3 in our sphinx search extension

@benjaoming
Copy link
Contributor

@stsewd we added this PR to the "iteration 0" milestone of the Diátaxis changes, so right now, I would hope that it's fixed up before Iteration 1 👍

@stsewd
Copy link
Member Author

stsewd commented Nov 17, 2022

so right now, I would hope that it's fixed up before Iteration 1

@benjaoming not sure what you mean with this p: should be fine to merge as is?

@benjaoming
Copy link
Contributor

@stsewd

@benjaoming not sure what you mean with this p: should be fine to merge as is?

Yes absolutely, I wanted to clarify the below question

cc @benjaoming in case any of this collides with the work of moving our docs to diataxis

The answer is basically no, please merge, and that even resolves one of the items in the Diátaxis milestone 👍 🎉

@ericholscher
Copy link
Member

ericholscher commented Nov 17, 2022

Use api v3 in our embedded js search

@stsewd What is this exactly? The indoc search that isn't using our extension?

Use api v2 in our sphinx search extension

I don't fully understand why our extension would use v2 instead of v3?

@stsewd
Copy link
Member Author

stsewd commented Nov 21, 2022

I don't fully understand why our extension would use v2 instead of v3?

opps, that was my mistake, I meant to say "Use api v3 in our sphinx search extension"

Use api v3 in our embedded js search

@stsewd What is this exactly? The indoc search that isn't using our extension?

yes

@benjaoming
Copy link
Contributor

@stsewd I've added Fixes #9573

Copy link
Member

@ericholscher ericholscher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'm OK merging this, and if I can get it tested on Monday that will be useful, but otherwise it feels safe to deploy. We can continue to iterate on it as we get real user feedback, but there's a bunch of improvements here that I'm excited about. 👍

@ericholscher ericholscher merged commit 624b13d into main Nov 25, 2022
@ericholscher ericholscher deleted the search-api-v3-implementation branch November 25, 2022 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Docs: update search page Subproject search sharing sibling search index
4 participants