Elasticsearch: Search doesn't work with OpenSearch #935
Labels
No labels
approved, awaiting change
broken setup
bug
cannot reproduce
configuration
documentation
duplicate
enhancement
extremely low priority
feature request
Fix it yourself
help wanted
invalid
mastodon_api
needs change/feedback
needs docs
needs tests
not a bug
not our bug
planned
pleroma_api
privacy
question
static_fe
triage
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
AkkomaGang/akkoma#935
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I know this is not a bug because Akkoma doesn't officially support OpenSearch. However, given the current license status of the Elasticsearch and OpenSearch, I am sure some folk might want to go with the community-driven OpenSearch, instead of Elasticsearch as a private company. More back stories here.
Since OpenSearch is a fork of Elasticsearch, they share very similar API interface. So I want to give OpenSearch a shot. Long story short, I spined off an OpenSearch instance on my home server and followed the documentation to set it up as Elasticsearch. Indexing works fine. However, searching returns an error line in the log:
Error log
With this hint:
[field_sort] unknown field [format], I found the Akkoma code which generates the Elasticsearch query:sort: ["_score",%{"_timestamp" => %{order: "desc", format: "basic_date_time"}}],This
formatfield in thesortobject is an Elasticsearch 7.13 feature introduced after the OpenSearch fork based on Elasticsearch 7.10. Therefore, it is expected to complain about the unknown field.Looking at Akkoma code, it seems that Akkoma doesn't really require the
_timestampfield to be formatted in a certain way, because only the_idfield is used:with {:ok, results} <- search(:raw, "activities", q) doresults|> Enum.map(fn result -> result["_id"] end)|> Pleroma.Activity.all_by_ids_with_object()Therefore, it should be safe to remove the
formatfield from thesortobject in the Elasticsearch query. And this simple change would make it compatible with OpenSearch. I am running it on my server, and it works.