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(atomic, headless): add support for sort criteria alphanumericNatural #4493

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

fpbrault
Copy link
Contributor

@fpbrault fpbrault commented Oct 3, 2024

This PR adds support for the alphanumericNatural and alphanumericNaturalDescending sort criteria for facets in headless and atomic.

https://coveord.atlassian.net/browse/KIT-3528

Copy link

github-actions bot commented Oct 3, 2024

Pull Request Report

PR Title

✅ Title follows the conventional commit spec.

Live demo links

Bundle Size

File Old (kb) New (kb) Change (%)
case-assist 236.8 237 0.1
commerce 341.5 341.7 0.1
search 412.8 413.1 0.1
insight 402.1 402.4 0.1
recommendation 249.1 249.3 0.1
ssr 406.3 406.6 0.1
ssr-commerce 353.7 353.9 0.1

SSR Progress

Use case SSR (#) CSR (#) Progress (%)
search 39 44 89
recommendation 0 4 0
case-assist 0 6 0
insight 0 27 0
commerce 0 15 0
Detailed logs search : buildInteractiveResult
search : buildInteractiveInstantResult
search : buildInteractiveRecentResult
search : buildInteractiveCitation
search : buildGeneratedAnswer
recommendation : missing SSR support
case-assist : missing SSR support
insight : missing SSR support
commerce : missing SSR support

@@ -174,7 +174,7 @@ export class AtomicFacet implements InitializableComponent {
@Prop({reflect: true}) public withSearch = true;
/**
* The sort criterion to apply to the returned facet values.
* Possible values are 'score', 'alphanumeric', 'alphanumericDescending', 'occurrences', and 'automatic'.
* Possible values are 'score', 'alphanumeric', 'alphanumericDescending', 'occurrences', alphanumericNatural', 'alphanumericNaturalDescending' and 'automatic'.
*/
@Prop({reflect: true}) public sortCriteria: FacetSortCriterion = 'automatic';
Copy link
Contributor

Choose a reason for hiding this comment

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

The interface FacetSortCriterion does not contain alphanumericNatural' & alphanumericNaturalDescending.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This PR adds them!

Comment on lines +1 to +2
import {FacetSortCriterion} from '@coveo/headless';
import {orderBy} from 'natural-orderby';
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think adding a dependency is necessary for tests. Is there other ways you can test this ? Or at least put it in devDependencies ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep def should be in dev deps. Extracting the sorting logic from natural-orderby would be too much work.

I tried with natural-compare-lite and javascript-natural-sort, which are already in our deps, but they don't sort in the same way as the index...

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