-
Notifications
You must be signed in to change notification settings - Fork 802
Is it possible to automatically set the parent for routing? #109
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
Comments
I wouldn't do it like that... Why have some kind of "DSL" for a thing like this... By the way, I wonder if I do something wrong in the message, because the README says quite emphatically: “In case you would need more control of the indexing process, you can implement these callbacks yourself, by hooking into after_create, after_save, after_update or after_destroy operations”. What's the problem with defining your own callbacks? Why would the "automatic callbacks" be so smart they handle all potential cases? I'm asking because this came up in #108 as well, and I honestly don't know how to message this in a better and more clear way. |
I suppose I looked at I don't believe overriding the callbacks will set the the parent on bulk imports though, will it? |
With regard to the documentation, perhaps it's not explicit enough. Automatic CallbacksYou can automatically update the index whenever the record changes ... |
@AaronRustad Yeah, I mean the very next header... (Custom Callbacks) |
No, that again must be customised, and I think there should be a nice a way to manipulate the JSON being sent during _bulk. |
Hi @karmi, I spent some time this afternoon looking at a possible solution for importing records and assigning the parent. Let me know what you think of this: https://github.com/AaronRustad/elasticsearch-rails/compare/set_parent_id_for_import I believe it's along the lines of what you're thinking. (UPDATE by @karmi: Changed the link to the Git compare view) |
@AaronRustad It's a "consistent" solution to the problem, in line with eg. the So, when somebody else has another requirement, what should we do, add another environment variable? A much more generic solution, allowing everybody to customize/change the serialization of individual records, would be to pass a block to the Tire.index 'articles' do
import articles do |documents|
documents.each { |document| document[:title].capitalize! }
end
refresh
end The trouble, of course, is that the |
I'm closing this issue. I submitted Pull Request #113 which satisfies my original question and allows future expansion of additional import capabilities. |
Currently, is it only possible to set the parent on a document via callbacks as suggested in the Parent/Child Example?
I would think that the library should be able identify a parent_id and set it if possible... perhaps something like:
If there is already way to do it other than overriding the callbacks, please let me know. If no, if you have thoughts how how it should work, I'd be willing to take a stab at coding up that functionality.
I guess this also would extend into
importing
as well.The text was updated successfully, but these errors were encountered: