Support for Search API Spellcheck

Created on 22 June 2024, 6 months ago
Updated 7 September 2024, 4 months ago

Problem/Motivation

We advertise on project page Search API Spellcheck and composer.json suggest it, however our code does not seem to support it yet. So add it with test coverage.

See https://git.drupalcode.org/project/search_api_opensearch/-/merge_request... and https://git.drupalcode.org/project/search_api_opensearch/-/merge_request... for reference, if the MLT changes in diff are relevent, please include them.

Steps to reproduce

  1. Make sure you have a local Elasticsearch 8 instance (I used version 8.14.1)
  2. Install Drupal core (I used 10.2.7) using the Standard install profile. Install this branch of elasticsearch_connector, search_api-8.x-1.35, and search_api_spellcheck-4.0.1.
  3. Go to /admin/config/search/search-api/add-server and create a Server that connects to your local Elasticsearch 8 instance.
  4. Go to /admin/config/search/search-api/add-index and create an Index named "Test", adding Content as a data source, that connects to the Server you created in the previous step. After saving, add the "Title" field, and set its type to "Elasticsearch Spellcheck".
  5. Go to /admin/structure/views/add, and create a view named "Search", showing "Index Test"; and create a page. Then click "Save and edit". Under "Filter criteria", click "Add", then check "Fulltext search" and click "Add". Check "Expose this filter to viewers, to allow them to change it". Under "Header", click "Add", then check "Search API Spellcheck "Did You Mean"", and click "Add". Check "Display even if view has no result"; and uncheck "Hide when the view has results". Save the view.
  6. Go to /node/add/page and add two pages whose title contains the word "lorem".
  7. Go to /admin/config/search/search-api, click the title of the Index, and make that the nodes you created have been indexed.
  8. Visit the view page (by default, at /search if you named the view "Search"), and enter "llorem" in the "Fulltext" search, and click "Apply". You should see "Did you mean: lorem ?" displayed at the top of the view.

Proposed resolution

Implement our own version of search_api_spellcheck code, inspired by the merge requests project/search_api_opensearch!39 and project/search_api_opensearch!48.

Remaining tasks

User interface changes

Adds an "Elasticsearch Spellcheck" Search API Index Field type.

API changes

API additions only.

Data model changes

None.

Feature request
Status

Fixed

Version

8.0

Component

Code

Created by

🇫🇮Finland sokru

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024