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

Contextual doc version search (Algolia/DocSearch) #3396

Closed
slorber opened this issue Sep 3, 2020 · 7 comments · Fixed by #3550
Closed

Contextual doc version search (Algolia/DocSearch) #3396

slorber opened this issue Sep 3, 2020 · 7 comments · Fixed by #3550
Labels
feature This is not a bug or issue with Docusausus, per se. It is a feature request for the future.

Comments

@slorber
Copy link
Collaborator

slorber commented Sep 3, 2020

🚀 Feature

A site can be versioned. In such case it's likely we want to use an Algolia DocSearch facet filter so that we don't end up with duplicate results:

    algolia: {
      apiKey: 'x',
      indexName: 'y',
      searchParameters: {
        facetFilters: [`version:${versions[0]}`],
      },
    },

This works, but also has some drawbacks: if you are currently browsing v1, and last version is v2, when you search, you will find v2 results.

We should make this facetting behavior contextual/dynamic, instead of being hardcoded in the site config, and if user is currently browsing v1, we should facet on v1, show him v1 related results.


Note: the solution must play well with docs multi-instance support. If you have:

  • Android SDK in version v1, v2, v3
  • iOS SDK in version v4, v5, v6

What should happen if:

  • you type some Android related keyword while you are browsing iOS doc?
  • you are not browsing any doc at all (ie you are on the homepage, the blog?)
@slorber slorber added the feature This is not a bug or issue with Docusausus, per se. It is a feature request for the future. label Sep 3, 2020
@amimas
Copy link

amimas commented Sep 17, 2020

Is this related to V2? I'm currently using V1 and it works the way you explained it should. Whichever version of documents I am on, the search results are from that version only.

@slorber
Copy link
Collaborator Author

slorber commented Sep 29, 2020

@amimas according to what I see, yes contextual search works on v1, but not on v2.

I see this code on v1 responsible for contextual doc search:

image

image

For v2 we'll need something similar, but also take into account docs multi-instance, and maybe it's worth to add the possibility to search non-docs things (blog posts, pages), as it seems currently unsupported on v1.

@slorber
Copy link
Collaborator Author

slorber commented Oct 6, 2020

Important to consider: if we persist a "preferred version" we probably should search in this version when searching on unversioned pages (see also #3543)

@amimas
Copy link

amimas commented Oct 11, 2020

For v2 we'll need something similar, but also take into account docs multi-instance

Not sure what is "docs multi-instance" @slorber .

@slorber
Copy link
Collaborator Author

slorber commented Oct 12, 2020

@amimas not well documented yet but you can understand the idea here: #3299

One Docusaurus site can host the doc for 2 sdks (like ios + android) that have different versions/release cycles.

@amimas
Copy link

amimas commented Oct 12, 2020

Thanks for the reference @slorber .

Sounds like a neat feature. I am actually doing something like this using V1 already. I have separate Docusaurus V1 instances for different tools and they are all deployed at subfolder from the root of the domain. Each docusaurus instance has its own versioning and search index with algolia. As a result, when you are in a page doing a search, the search is already contextual based on the tool and the version being viewed. A landing page at the root is deployed using another generator that brings the whole site together.

Anyways, if we have "multi-instance" docs in V2, then yes, that should be in the consideration of contextual search.

@slorber
Copy link
Collaborator Author

slorber commented Oct 12, 2020

Great, hope we'll be able to solve your usecase.
Although if you have large sites to assemble it may be better to keep them separated to avoid long build times.

There's already a PR here: #3543, but waiting for Algolia inputs to complete it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature This is not a bug or issue with Docusausus, per se. It is a feature request for the future.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants