Skip to content

feat(elasticsearch): use _chipStr instead of _sortKeyByLang for spelling suggestions#1698

Merged
andersju merged 1 commit intodevelopfrom
feature/lws-424-improve-spelling-suggestions
Feb 23, 2026
Merged

feat(elasticsearch): use _chipStr instead of _sortKeyByLang for spelling suggestions#1698
andersju merged 1 commit intodevelopfrom
feature/lws-424-improve-spelling-suggestions

Conversation

@andersju
Copy link
Member

Currently we use _sortKeyByLang.sv for "did you mean....?" spelling suggestions. This is less than ideal. Here's an instance, "Jag tar inte farväl" by Han Kang: https://libris.kb.se/2m16tzmd08b73b4g

Its _sortKeyByLang.sv is "Jag tar inte farväl, Svenska". No author there. So in Libris sök ham tar inte farväl results in no suggestions; "kangg tar inte farväl" results in the suggestion "könig tar inte farväl"; and so on. More generally <part of author name> <part of title> doesn't work at all because there's no connection between contributor and title in _sortKeyByLang.

However, _chipStr contains both of those things. In this example "Jag tar inte farväl Jag tar inte farväl Svenska Swedish Han Kang 1970-". So it should work better.

I've also experimented with custom lenses and custom ES fields only for spelling, but this might be good enough, possibly after tinkering with the parameters of the ES spell suggestion query (https://www.elastic.co/guide/en/elasticsearch/reference/8.11/search-suggesters.html#phrase-suggester).

Anyway, need to test it with all the data and not just the tiny dev data to see if this is enough. It should at the very least be better than now.

https://kbse.atlassian.net/browse/LWS-424

Copy link
Contributor

@olovy olovy left a comment

Choose a reason for hiding this comment

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

LGTM!

We need to make sure that spell checking fails silently when using the new SPELL_CHECK_FIELD with the old index (during first reindex).

@andersju andersju merged commit e8c8b8f into develop Feb 23, 2026
1 check passed
@andersju andersju deleted the feature/lws-424-improve-spelling-suggestions branch February 23, 2026 08:47
andersju added a commit that referenced this pull request Feb 23, 2026
…spelling-suggestions"

This reverts commit e8c8b8f, reversing
changes made to 4dda2ba.
@andersju
Copy link
Member Author

Turns out _sortKeyByLang is about to get the necessary data, so I reverted this one.

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