-
Notifications
You must be signed in to change notification settings - Fork 433
feat(v4): Add support for multi-index search #2736
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
Conversation
✅ Deploy Preview for docsearch ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reporting a retro-compatibility issue we got after upgrading from beta.8 to GA
Please tell us if you plan to restore API retro-compatibility for subcomponents too, or if we now have to handle this retro-compatibility ourselves.
| // Format the `indexes` to be used until `indexName` and `searchParameters` props are fully removed. | ||
| const indexes: DocSearchIndex[] = []; | ||
|
|
||
| if (indexName && indexName !== '') { | ||
| indexes.push({ | ||
| name: indexName, | ||
| searchParameters, | ||
| }); | ||
| } | ||
|
|
||
| if (indices.length > 0) { | ||
| indices.forEach((index) => { | ||
| indexes.push(typeof index === 'string' ? { name: index } : index); | ||
| }); | ||
| } | ||
|
|
||
| if (indexes.length < 1) { | ||
| throw new Error('Must supply either `indexName` or `indices` for DocSearch to work'); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I understand, this fallback logic only applies when using <DocSearch>, but it doesn't apply when using <DocSearchButton> and <DocSearchModal> directly, like Docusaurus does.
Unfortunately, this PR broke the DocSearch v3/v4 retrocompatibility we expected for Docusaurus, and upgrading from beta8 to GA makes the search unusable: facebook/docusaurus#11327
| translations={props?.translations?.modal} | ||
| isAskAiActive={isAskAiActive} | ||
| canHandleAskAi={canHandleAskAi} | ||
| indexes={indexes} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is DocSearch prop named indices, while subcomponents accept an indexes prop? Isn't that a typo? Why not always a consistent name?
| describe('Indexes', () => { | ||
| it('renders with deprecated indexName prop', () => { | ||
| expect(() => <DocSearch indexName="My test Index" />).not.toThrowError(); | ||
| }); | ||
|
|
||
| it('renders with new indices prop', () => { | ||
| expect(() => render(<DocSearch indexName={undefined} indices={[{ name: 'testing' }]} />)).not.toThrowError(); | ||
| }); | ||
|
|
||
| it('throws an error if indexName or indices are not provided', () => { | ||
| expect(() => render(<DocSearch indexName={undefined} indices={[]} />)).toThrowError(); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those tests only cover the root API, but do not cover <DocSearchButton> and <DocSearchModal> APIs
What
Adds support for multi-index search during keyword search. This does not impact AskAI in any way.
indicesproperty to accept a list of indexes for searchindexNameandsearchParameterspropertiesindexNameandsearchParametersare fully removedDocs
indicesand deprecation warnings forindexNameandsearchParametersrespectPrefersColorSchemewithin Docusaurus configDependencies