-
Couldn't load subscription status.
- Fork 808
Add the ability to define how models are mapped to hits. #428
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
Add the ability to define how models are mapped to hits. #428
Conversation
Is there any interest in seeing this merged... I know I am! ;-)
hongsheng-razoo
commented
May 31, 2016
I am facing the exact same problem ... can we merge this solution?
Hi, ugh, this is one of the PRs which has slipped by... I was concentrated on other things for a long strecth of time, and in the last weeks was more focused on the Ruby client (preparing for the 5.0 release and similar).
I like the idea of a lambda, @AaronRustad, you know I do :) I'll look into this today or tomorrow, please bug me until we sort this out. Sorry to put the strain on you, but it would help me...
gareth
commented
Jul 1, 2016
This error has just bitten us too, I'm definitely interested in getting a solution merged
Lol, I haven't bugged you for a while @karmi .... I've since moved on and I'm not sure there is any interest in this any more. Shall we close it?
We just hit our heads on this while shipping a bunch of stuff into production.
@karmi The default behaviour should allow the index name followed by anything to match.
Elasticsearch::Model.model_to_hit_selector = lambda do |model, hit| /#{model.index_name}.*/ =~ hit[:_index] && model.document_type == hit[:_type] end
This PR addresses #421
When searching against aliases, results from
Elasticsearchare returned with the actual_indexname rather than the alias name. The current implementation of Multiple Model Search uses the_indexto determine which model to use. Unfortunately, when working with an aliased index, this mapping fails.I don't think there is a 'correct' way to get around this, other than to give the user of the library the option of setting the logic for determining how to map indices to aliased models.
This PR gives the option of overriding the default
modeltohitselection code.For example, in production, I'll use a timestamped index like `content-20150515164511'.