Fix highlight issue with apostrophes

Created on 25 January 2022, over 3 years ago
Updated 15 April 2025, 12 days ago

Problem/Motivation

The issue can occur:

  • with apostrophes or similar characters which are stripped as individual words: https://git.drupalcode.org/project/search_api/-/blob/8.x-1.x/src/Plugin/... . For example the term "children's" is split into ["chidren',"s"].
  • with quoted search terms. For example "children's toys" is split into ["children", "s", "toys"]. So a quoted query which should highlight "childrens toys" highlights "children", "s", and "toys".

Steps to reproduce

1. Install Search API 8.x-1.x and Search API Solr 4.x and Solr Server 8.4.
2. Create Solr Server with "Retrieve highlighted snippets" selected.
3. Create Index that includes fulltext field for body content and enable the Highlight process with "Create Excerpt".
4. Create a test content that includes apostrophes and terms "toys", and "son's toys" with fulltext fields.
5. Create search page in views that uses "Multiple words" parse mode for the fulltext fields.
6. Search terms that include apostrophes, ie "son't toys".
7. The results will include highlighted "s", "toys" and "toy".

Proposed resolution

There is an issue already opened for search api 🐛 Add option to skip highlighted term processing Needs work and I suggest to use this patch 🐛 Add option to skip highlighted term processing Needs work

Remaining tasks

  • ✅ File an issue about this project
  • ❌ Addition/Change/Update/Fix to this project
  • ❌ Testing to ensure no regression
  • ❌ Automated unit/functional testing coverage
  • ❌ Developer Documentation support on feature change/addition
  • ❌ User Guide Documentation support on feature change/addition
  • ❌ Update Release Notes and Update Helper on new feature change/addition
  • ❌ Code review from 1 Varbase core team member
  • ❌ Full testing and approval
  • ❌ Credit contributors
  • ❌ Review with the product owner
  • ❌ Release

Varbase update type:

  • ✅ No Update
  • ➖ Optional Update
  • ➖ Forced Update
  • ➖ Forced Update if Unchanged

User interface changes

  • N/A

API changes

  • N/A

Data model changes

  • N/A
🐛 Bug report
Status

Closed: outdated

Version

9.0

Component

Code

Created by

🇯🇴Jordan Odai Atieh Amman

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024