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

Design doc: new search API #9533

Merged
merged 6 commits into from
Nov 17, 2022
Merged
Changes from 1 commit
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
113 changes: 84 additions & 29 deletions docs/dev/design/new-search-api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Goals
- Allow to configure search at the API level,
instead of having the options in the database.
- Allow to search a group of projects/versions at the same time.
- Bring the same syntax to the dashboard search.

Syntax
------
Expand Down Expand Up @@ -56,7 +57,8 @@ project:
since ``:`` is already used to separate the key from the value.

Including subprojects
`````````````````````
~~~~~~~~~~~~~~~~~~~~~

Now that we are returning results only
from the given projects, we need an easy way to
include results from subprojects.
Expand Down Expand Up @@ -200,43 +202,96 @@ Examples

- ``search``: invalid, at least one project is required.

Dashboard search
----------------

This is the search feature that you can access from
the readthedocs.org/readthedocs.com domains.

We have two types:

Project scoped search:
Search files and versions of the curent project only.

Global search:
Search files and versions of all projects in .org,
and only the projects the user has access to in .com.

Global search also allows to search projects by name/description.

This search also allows you to see the number of results
from other projects/versions/sphinx domains (facets).

Project scoped search
~~~~~~~~~~~~~~~~~~~~~

Here the new syntax won't have effect,
since we are searching for the files of one project only!

Another approach could be linking to the global search
with ``project:{project.slug}`` filled in the query.
Comment on lines +250 to +251
Copy link
Member Author

Choose a reason for hiding this comment

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

If we do this, we could do something similar to github, having a global search bar, and offering the scopes depending if you are on a project/organization or not.

Screenshot from 2022-08-31 19-02-43

Copy link
Member

Choose a reason for hiding this comment

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

Yea, that is what I'm imagining. Basically we just prepend the project slug in project search mode, but the same UX can be used globally.

Copy link
Member Author

Choose a reason for hiding this comment

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

So, are we okay for now to just redirect to the global search with the filter set when clicking on Search in

Screenshot 2022-09-01 at 12-50-19 docs Read the Docs

or do we want to have the new search bar together with this implementation?


Global search (projects)
~~~~~~~~~~~~~~~~~~~~~~~~

We can keep the project search as is,
without using the new syntax (since it doesn't make sense there).
Copy link
Member

Choose a reason for hiding this comment

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

I think for .org, we probably want some kind of "explore" functionality. It's not a huge priority, but I think that's the natural outcome of project search & tag data. But outside the scope of this document.

What does "as is" mean here? Is it the same search bar? A different one?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, the same search bar, as an option

Screenshot 2022-09-01 at 12-25-37 Search docs Read the Docs


Global search (files)
~~~~~~~~~~~~~~~~~~~~~

Using the same syntax from the API will be allowed,
by default it will search all projects in .org,
Copy link
Member

Choose a reason for hiding this comment

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

I think we should switch this to searching your projects by default on .org too, but with an obvious for global?

Copy link
Member Author

Choose a reason for hiding this comment

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

We can start the search with the user:@me filter set, and if you want a global search, you just remove that filter.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good 👍

and all projects the user has access to in .com.

Another approach could be to allow
filtering by user on .org, this is ``user:stsewd`` or ``user:@me``
so a user can search all their projects easily.
We could allow just ``@me`` to start.
Copy link
Member

Choose a reason for hiding this comment

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

This is a neat idea. This is the start of something like collections #3784 that I've talked about for a long time, if we added tag: filtering, for example. We probably want org: filtering too.

Copy link
Member

Choose a reason for hiding this comment

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

These would be definitely great additions! 💯


Facets
~~~~~~

We can keep the facets, but they would be a little different,
since with the new syntax we need to specify a project in order to search for
a version, i.e, we can't search all ``latest`` versions of all projects.

By default we will use/show the ``project`` facet,
and after the user has filtered by a project,
we will use/show the ``version`` facet.

If the user searches more than one project,
things get complicated, should we keep showing the ``version`` facet?
If clicked, should we change the version on all the projects?

If that is too complicated to explain/implement,
we should be fine by just supporting the ``project``
facet for now.

Backwards compatibility
~~~~~~~~~~~~~~~~~~~~~~~

We should be able to keep the old URLs working in the global search,
but we could also just ignore the old syntax, or transform
the old syntax to the new one and redirect the user to it,
for example ``?q=test&project=docs&version=latest``
would be transformed to ``?q=test project:docs/latest``.

Future features
---------------

- Allow searching on several versions of the same project
(the API response is prepared to support this).
- Allow searching on all versions of a project easily,
with a syntax like ``project:docs/*`` or ``project:docs/@all``.
- Allow specify the type of search:

- Multi match (query as is)
- Simple query string (allows using the ES query syntax)
- Fuzzy search (same as multi match, but with with fuzziness)

Questions / pending decisions
-----------------------------

Integration with the dashboard search.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The search API and the search from the dashboard
use the same backend, but they are used in a different way.

The dashboard search by default searches on all projects (.org),
or all project the current user has access to (.com).
And the API search searches on explicitly given projects.

The dashboard search allows filtering by version and role,
the API search allows filtering only by version (and it's required).

The dashboard search makes use of filters in order to return
the number of results from other versions/roles.
Is this feature useful? It could slow down the response.
Searching several versions at the same time could be a better replace?

The dashboard search can be used to search for projects
by their name and description.
The API search doesn't support this.
Is this feature useful? Should we implement
this as a way to filter projects from https://readthedocs.org/dashboard/ instead?
This will be using just https://docs.djangoproject.com/en/4.0/ref/contrib/postgres/search/
or ``contains``.
- Add the ``organization`` filter,
so users can search by all projects that belong
to an organization.
Would we show results of all versions
or just the default version?