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

Add rankingScore and rankingScoreDetails types #1537

Merged
merged 7 commits into from
Jul 12, 2023

Conversation

bidoubiwa
Copy link
Contributor

Related to:

issue: meilisearch/meilisearch#3771
spec: meilisearch/specifications#252

What does this PR do?

  • (types) Add the searchParameters: showRankingScore and showRankingScoreDetails
  • (types) Adds the fields _rankingScore and _rankingScoreDetails in the returned hits depending on the enabled features

@bidoubiwa bidoubiwa added the enhancement New feature or request label Jul 10, 2023
Base automatically changed from experimental_vector_search to bump-meilisearch-v1.3.0 July 10, 2023 14:58
_rankingScoreDetails?: Record<string, any>
}

export type RakingScoreDetails = {
Copy link
Member

Choose a reason for hiding this comment

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

Is there any way to add comments to these types, to make them highlight the IDEs of people using it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I realised I forgot to use RankingScoreDetails hehe. But to answer your question this is how IDe works w/ typescript types.

Screenshot 2023-07-11 at 11 53 29 Screenshot 2023-07-11 at 11 53 55

By clicking on go to type definition you'll be redirection to the RankingScoreDetails type.

Now, I can add a comment like this:

Screenshot 2023-07-11 at 11 55 53 Screenshot 2023-07-11 at 11 57 05

Which would appear like that if I hover over the type (see last line of second screen):

Screenshot 2023-07-11 at 11 57 00


const hit = response.hits[0]

expect(response).toHaveProperty('hits', expect.any(Array))
Copy link
Member

Choose a reason for hiding this comment

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

This assertion is not valid since you'll have a broken code anyway. In the line before you ensure you're taking the first item from an array :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not asserting hit but response. Not sure why it's broken

Copy link
Member

Choose a reason for hiding this comment

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

hits will always be an array, that's my point. Otherwise you'll have an exception!

Copy link
Member

Choose a reason for hiding this comment

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

In your assertion, you're telling that you expect the hits key to be an array. And that will never fail.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yes, it's a test that tests Meilisearch not my SDK haha. It's a copy paste from other tests I can remove it

@bidoubiwa bidoubiwa merged commit 0cf8704 into bump-meilisearch-v1.3.0 Jul 12, 2023
4 of 7 checks passed
@bidoubiwa bidoubiwa deleted the experimental_ranking_details branch July 12, 2023 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants