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

III-6275 Make Labels findable by using Levenshtein distance #1837

Closed
wants to merge 7 commits into from

Conversation

JonasVHG
Copy link
Contributor

@JonasVHG JonasVHG commented Oct 14, 2024

Changed

  • ReadRepositoryInterface, DBALReadRepository, AppConfigReadRepositoryDecorator & GodUserReadRepositoryDecorator: Add searchByLevenshtein() functionality.
  • SearchLabelsRequestHandler: Use searchByLevenshtein() instead of search()
  • tests/SearchLabelsRequestHandlerTest: Update test with new functionality
  • tests/DBALReadRepositoryTest: Add unit tests for alphabetically & Levenshtein search.
  • features/label/get.feature: Update acceptance test

Fixed

  • Searching for labels mantelzorgers will return a more exact list instead of alphabetically sorted labels.

Ticket: https://jira.publiq.be/browse/III-6275

@JonasVHG JonasVHG marked this pull request as ready for review October 14, 2024 11:13
@LucWollants
Copy link
Contributor

As discussed through Slack this solution will not return the exact match if this was not returned as one of the first n results of the default query.

@JonasVHG
Copy link
Contributor Author

This is not the correct approach.
A better solution would be something like:
SELECT uuid_col, name, visible, private, excluded, rank FROM ( SELECT uuid_col, name, visible, private, excluded, (CASE WHEN name = 'abc' THEN 1 WHEN name LIKE 'abc%' THEN 2 WHEN name LIKE '%abc%' THEN 3 ELSE 4 END) FROM labels_json WHERE name LIKE '%abc%' ) AS subquery ORDER BY rank ASC; which should be done in a different PR.

@JonasVHG JonasVHG closed this Oct 15, 2024
@JonasVHG JonasVHG deleted the III-6275-label-sort branch October 15, 2024 11:07
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