Skip to content

WID-588 - Improve autocomplete results for provinces#436

Merged
bertramakers merged 8 commits intomasterfrom
feature/WID-588
Oct 8, 2025
Merged

WID-588 - Improve autocomplete results for provinces#436
bertramakers merged 8 commits intomasterfrom
feature/WID-588

Conversation

@brampauwelyn
Copy link
Contributor

@brampauwelyn brampauwelyn commented Oct 7, 2025

Changed

A search on vlaams-brabant should return results e.g. provincie vlaams-brabant


Ticket: https://jira.publiq.be/browse/WID-588

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Enhances region autocomplete to return province matches when users search with hyphenated names (e.g., 'vlaams-brabant'), broadening matching from prefix-only to substring.

  • Changed prefix match (starts-with) to substring match for region name comparisons
  • Left existing explanatory comment unchanged, which now no longer matches the new behavior

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines 51 to 52
// This is done to find cities & towns with short names which also match lots of other cities & towns
// e.g., Zele or Egem
Copy link

Copilot AI Oct 7, 2025

Choose a reason for hiding this comment

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

The comment describes a prefix (starts-with) filtering strategy to limit overmatching of short names, but the condition was changed to a substring match (!== false). Update the comment to reflect the broader matching intent (e.g., supporting province name fragments), or revert to the prefix check if the original constraint is still desired.

Suggested change
// This is done to find cities & towns with short names which also match lots of other cities & towns
// e.g., Zele or Egem
// This is done to match the search string anywhere in the region name,
// supporting partial matches and fragments (e.g., matching province or city name fragments like "Zele" or "Egem").

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@JonasVHG JonasVHG left a comment

Choose a reason for hiding this comment

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

I think this will break the solution for https://jira.publiq.be/browse/WID-575
I do not know yet if there is an easy way to fix both problems.

@bertramakers
Copy link
Contributor

@JonasVHG Bram discovered the same issue based on the comment that Copilot pointed out. I discussed a potential solution with him, will do the change and commit it here and you / Koen can check if it seems logical or not. I'll also inform Sarah so she's up-to-date in case we deploy it and there are problems after all (in which case we can just revert the PR but mostly so she is aware what is going on).

@bertramakers
Copy link
Contributor

I committed some changes to sort the matches based on the kind of match. For example exact matches score higher than partial matches, and there are a lot of nuances in-between.

The overall order in this PR is now:

  • Exact match
  • Match with a known pattern like "Provincie X", "X + deelgemeenten", "Regio X" (e.g. "Zele + deelgemeenten" when searching for "Zele")
  • Matches at the start of the string, followed by a whitespace character (e.g. "Zele (Zele)" when searching for "Zele")
  • Matches at the start of the string, followed by a non-whitespace character (e.g. "Zelem (Halen)" when searching for "Zele")
  • Matches not at the start of the string but preceeded by ( or -, as supported before for subminicipalities and "informal" search like "Molenbeek" for "Sint-Jans-Molenbeek"
  • Any other kind of partial match

Keep in mind that the frontend limits the results to 10 matches so the partial matches at the end will probably be cut off except when there are very little matches (in which case it makes sense to show them.)

There are other ways to tweak this, but I think the best way to verify if this works as expected or needs changes is to deploy it to acc/test and maybe even prod after a quick sanity check and see if there is any feedback. Since it is hard to predict all possible use cases.

Also note that the tests didn't account for the order of the results before because the matches are an associative array. I fixed that by also comparing the arrays as lists as well as associative arrays. This is also explains some of the differences in the order in the tests.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

bertramakers and others added 4 commits October 7, 2025 15:58
Fix typos

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Contrary to assertEquals, assertSame also makes sure the order is the same in the case of associative arrays
@bertramakers bertramakers requested a review from Copilot October 7, 2025 14:09
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Contributor

@JonasVHG JonasVHG left a comment

Choose a reason for hiding this comment

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

Nice colution for lots of pesky problems.👍

@bertramakers bertramakers merged commit 66a629e into master Oct 8, 2025
1 check passed
@bertramakers bertramakers deleted the feature/WID-588 branch October 8, 2025 09:16
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.

3 participants