-
Notifications
You must be signed in to change notification settings - Fork 91
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
Control which search results are shown via a predicate function #275
Comments
I think it's possible, just like those using multi-versions, we can generate multiple indexes for each of your doc directories. I think we can provide an option to allow developers to do it by base path or specific directories. |
By the way, in your scenario, do you wish to search all docs when you're in the homepage |
If the answer is yes, we can't put the docs into different indexes, because if we do that, the search will not work in |
Thanks for the quick response @weareoutman! For our use case, we are okay with not having a search bar on the home page. The home page is a list/index of all of our SDKs and fairly easy to navigate. If required, we can always create a custom search bar on the homepage itself. Separate indexes per base path would be fantastic. It will cause less confusion for users when searching, since they expect to get results from the existing context itself. |
@weareoutman [
require.resolve("@easyops-cn/docusaurus-search-local"),
{
// ... other options
// creates separate indexes for these base paths
createIndexesByPaths: ["android", "ios", "web", ...]
}
] AND/OR [
require.resolve("@easyops-cn/docusaurus-search-local"),
{
// ... other options
// deep: false won't pick up any nested folders, while deep:true picks up all nested folders
createIndexesByPaths: [{path: "android", deep: false}, {path: "android/legacy", deep: true}]
}
] I think both mechanisms would be useful. I was looking at the source code to see how this could be implemented. I am slightly confused about where the index is getting generated as well as how the autocomplete component works. Thanks! |
There is a WIP branch, I couldn't finish it yet. I will continue this work this weekend if I got time. |
Checked the commits. Do you think it's a good idea to provide the user an option to give explicit groups of base paths like in my comment example above? |
Yes, I think an option with explicit paths would be better, it's also easier to implement. |
@hs-saunved Try v0.33.0 |
Hi @weareoutman Issue 1
Issue 2
Please let me know if you'd like me to create separate issues for this or if this is okay. Thank you! |
Issue 1 should have already been handled, needs investigation. For issue 2, I think we'd better to provide a new option, currently all pages which are not specified, will be considered as with a search context of ROOT. |
@hs-saunved Try v.0.33.1 with a new option: |
@weareoutman It is working as expected! I will test this out over the week and report any potential issues or optimizations. Thank you very much! |
We have a use case where we want to show only specific search results for specific pages.
E.g. If the user is in the
/android
path, only results from this path should be shown to them.Is it possible to achieve this currently? Is there a hook that we can use to filter the search results ourselves?
If not, would it be possible to create a mode that allows for a narrower search within the base path only?
Thanks!
Edit: I believe this issue is also related #99
The text was updated successfully, but these errors were encountered: