Index different objects to different indices
pbassut opened this issue · 2 comments
In order to include some specific documents in a ILM I need to separate the documents between the indices that tell something about those documents attributes. Think about the twitter app. I want all tweets that happened in October 2nd 2019 to be in the index tweets-2019-10-02
. Assuming such old tweets are not regularly looked at from our users, I can safely move that index to a weaker node.
It was recently introduced a way to pass a Proc to the index_name
attribute but that Proc doesn't receive the object being indexed.
I wonder if we should have a method we could overwrite like:
def object_index_name(object)
"#{object.class.name.tableize}_#{object.created_at.strftime("%Y-%m-%d")}_#{Rails.env}"
end
I understand that this library does bulk inserts and would have to group_by all documents that would go to an index or another based on the return of such a method
Additional context
Any other way I can tweak the library to do what I want there?
This was suggested as a comment here.
Wanted to create a dedicated post for it