Skip to content

Conversation

@marcosgz
Copy link
Owner

@marcosgz marcosgz commented Jul 30, 2025

Default Query Parameters

This PR adds a functionality that allows users to set default query parameters for :index, :update, :create and :delete operations of ElasticSearch/OpenSearch indexes.

One use case is the retry_on_conflict parameter, which can be set to a default value for all update operations. This way, users do not have to specify it every time they perform an update operation.

Example usage:

class UsersIndex < Esse::Index
  request_params(:update) do |_doc|
    { retry_on_conflict: 3 }
  end
end

Or you can define with static value

class UsersIndex < Esse::Index
  request_params(:update, retry_on_conflict: 3)
end

Now when performing an update or bulk update operation on the UsersIndex, the retry_on_conflict parameter will automatically be set to 3 unless overridden.

It will benefit callbacks of esse-async_indexing and esse-active_record gems, as you don't need to define callbacks passing the retry_on_conflict parameter every time.

This functionality is also one step close for the _type removal from the index, as it allows setting the document type for the index without explicit type implementation on this gem. We may use this for routing as well in future

@marcosgz marcosgz merged commit c127230 into main Aug 4, 2025
69 of 80 checks passed
@marcosgz marcosgz deleted the marcosgz/default-query-params branch August 4, 2025 20:51
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