-
Notifications
You must be signed in to change notification settings - Fork 368
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
How to define child/parent mappings? #56
Comments
Yeah, currently there is no way to do it. Indexing objects with parent is not supported for now. I need to dig deeper to figure out how to do this. Currently I think it should be like this: define_type Column.includes(:table) do
root _parent: { type: 'table' }, parent: -> { table.id } do
field ...
end
end Or maybe use |
Okay, I may work on this but for now it'd be nice to have a work-around for my use case. Basically there is a field in the parent that is expensive to calculate and is also needed for each of its children. If I could store results for this expensive function in a hash at index time then I could just look up in the hash instead of having to recalculate for each child. I tried doing something like this but just getting
Is there any way to do something like this? |
Yeah, sure, because value procs are called in the AR object context. Try |
Sorry, it is just a hash that stores permissions at index time. If the key for a specific table is already in the hash then it just does a lookup and the value at that key is the permission. If the key isn't there then it runs the expensive function to get the user permissions and stores it in the hash. So anytime a new index action is occurring (specifically reset and import), the hash should be reset to be empty (since permissions can change). Maybe I can use the chewy atomic block? |
I'm still thinking about how to implement such a case. Previous code will not work, I'm sure. But Don't even know. Maybe you have to redefine import method for index? To initialize TablePermissionsStore, but how to access it inside importer? Maybe use a kind of https://github.com/pyromaniac/contextuality to create variable inside the import context. Not sure. |
Okay, it seems like a work around will be pretty difficult so I'm just going to work on adding in parent/child mappings. |
https://gist.github.com/baothi/72c63fbb9b8b4675188e |
just place |
hi pyromaniac |
are you sure your file named |
https://www.youtube.com/watch?v=v_MCcue2uEA |
hi pyromaniac |
just try to execute |
hi pyromaniac |
hi pyromaniac |
I can't figure out how to define a child/parent mapping in chewy. The following gives a routing error, presumably because column isn't being given a parent _id.
I can't find any examples of parent ids being given anywhere other than the url (like the examples here http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/indexing-parent-child.html). Is it possible to specify a parent id in chewy currently or does there need to be some code added?
The text was updated successfully, but these errors were encountered: