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

feat(algolia): fix highlighting hit type #452

Merged
merged 1 commit into from
Feb 19, 2021

Conversation

francoischalifour
Copy link
Member

This updates our requirements for highlighting a hit.

Description

We used to expect a hit to contain an objectID property because Algolia hits owns it. However, we also support highlighting for Recent Searches and facet hits, which aren't strictly Algolia hits, and therefore don't own an objectID property.

We now expect an _highlightResult for highlightHit and _snippetResult for snippetHit, which is more accurate.

Related

props: ParseAlgoliaHitParams<THit>
): ParsedAttribute[] {
export function parseAlgoliaHitReverseHighlight<
THit extends HighlightedHit<unknown>
Copy link
Contributor

Choose a reason for hiding this comment

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

You suggested Record<string, unknown> in message, any reason why you changed it to unknown again?

Copy link
Member Author

Choose a reason for hiding this comment

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

Given:

import { HighlightResult } from '@algolia/client-search';

export type HighlightedHit<THit> = THit & {
  _highlightResult?: HighlightResult<THit>;
};

I tried HighlightResult<Record<string, unknown>> with a DocSearch hit and it doesn't work because properties can be null (e.g., content).

We need to improve the client's HighlightResult type to allow this.

@francoischalifour francoischalifour merged commit 0f92710 into next Feb 19, 2021
@francoischalifour francoischalifour deleted the fix/highlight-hit-type branch February 19, 2021 07:57
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.

2 participants