Skip to content

[5.x] Check ES types for keyword instead of guessing#1201

Merged
royduin merged 3 commits intomasterfrom
feature/check-elasticsearch-types
Feb 24, 2026
Merged

[5.x] Check ES types for keyword instead of guessing#1201
royduin merged 3 commits intomasterfrom
feature/check-elasticsearch-types

Conversation

@Jade-GG
Copy link
Copy Markdown
Collaborator

@Jade-GG Jade-GG commented Feb 19, 2026

ref: FW-2261

Previously, we relied on some heuristics to check whether a type needed to have a .keyword or not in the ES query. However, this was unreliable. Specifically we ran into this with the created_at field which in one of our projects was inexplicably set to text instead of date.

We could have just changed this one attribute, however I found 2 problems with that:

  1. I don't know whether that will break anything else there.
  2. It's very likely we'll encounter more examples of this going wrong, as we have in the past.

On the other hand, this solution also has some problems. We really need to rely on cache to not make all requests slow AF, so I've tried to make sure that the cache gets cleared and then warmed after every index. This will also not work well when there is no index yet, however that should be fine because without any indexed data the .keyword isn't relevant anyway.


For this solution I added two new events that are similar to the IndexBeforeEvent/IndexAfterEvent events, that instead fire on a per-store basis. This allows me to clear and warm the cached mappings per store.

Comment thread src/Models/Traits/Searchable.php
@royduin royduin merged commit 7058c0a into master Feb 24, 2026
15 checks passed
@royduin royduin deleted the feature/check-elasticsearch-types branch February 24, 2026 10:03
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