Skip to content

Add option to highlight search result matches#2331

Open
danloveg wants to merge 14 commits intoartefactual:qa/2.xfrom
danloveg:dev/search-highlighting
Open

Add option to highlight search result matches#2331
danloveg wants to merge 14 commits intoartefactual:qa/2.xfrom
danloveg:dev/search-highlighting

Conversation

@danloveg
Copy link
Copy Markdown
Contributor

@danloveg danloveg commented Apr 1, 2026

Adds an option to highlight search results for information objects. I've been working with researchers using AtoM recently and they mentioned that being able to see why certain descriptions are returned in the search results at a glance would be a useful feature. This PR adds subtle highlighting to search results to show what text matched the search query. If the title, scope and content, or creator is matched on, then those highlights are added inline to the existing rendered fields. If other fields that are not typically included in the search results are matched on, they are added in a new block. See here:

highlight

Elasticsearch already has this capability, it was just a matter of turning highlighting on and rendering its results. It returns matches wrapped in <mark></mark> tags.

Since administrators might not want this active, you can disable it in the settings. I've made it enabled by default.

setting

I understand this feature probably won't make it for 2.11 but thought I'd open this pull request in case this would be a useful feature for others, as well.

@sarah-mason sarah-mason added the Community Pull requests that have been contributed from community members outside Artefactual label Apr 9, 2026
@anvit
Copy link
Copy Markdown
Contributor

anvit commented Apr 16, 2026

Hi @danloveg , we'd been testing this feature out, and it looks great! We had a couple of minor things we noticed during testing that we wanted to flag:

  • Currently the contrast ratio for the highlight colour against the background colour is too low. I would recommend picking a darker/more saturated shade. You could use Web AIM's contrast checker to test a chosen colour and confirm that it meets the accessibility standards.
  • When a language is picked to narrow down search results, the language code itself shows up as a match. Not sure if this is something that's easy to fix since I haven't dived into this PR yet.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Community Pull requests that have been contributed from community members outside Artefactual

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants