Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Index different objects to different indices #1661

Closed
pbassut opened this issue Dec 22, 2023 · 2 comments
Closed

Index different objects to different indices #1661

pbassut opened this issue Dec 22, 2023 · 2 comments

Comments

@pbassut
Copy link

pbassut commented Dec 22, 2023

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?

@pbassut
Copy link
Author

pbassut commented Dec 22, 2023

This was suggested as a comment here.
Wanted to create a dedicated post for it

@ankane
Copy link
Owner

ankane commented Jun 17, 2024

Hi @pbassut, thanks for the suggestion. However, it's more complexity than I'd like to maintain.

@ankane ankane closed this as completed Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants