elastic / elasticsearch-rails

Elasticsearch integrations for ActiveModel/Record and Ruby on Rails
Apache License 2.0
3.08k stars 798 forks source link

Make _id overrideable to provide support for Gems like acts_as #974

Open Fleick opened 3 years ago

Fleick commented 3 years ago

Hello all,

would it be possible to make the _id of Elasticsearch overridable by method? Unfortunately there are problems with gems that allows multi table inheritance (like acts_as), because model.id in elastichsearch.index_document takes the ID of the specific model - but the ID of the generic one would be necessary. To take the first example from the Gem, we have to make sure that always the ID of Product is taken and not the one of Pen or Book. As far as I can see in the doc and in the Code line 112 there is currently no way to override _id.
To solve the problem in general I would recommend to create the possibility to implement a method _id on the model. This should override the default behavior.

picandocodigo commented 3 years ago

Hi @Fleick, Thanks for reporting this, I'll be working on this library soon after the release of the Elastic stack 7.11 and I'll take a look at this issue.

Cheers!

Fleick commented 3 years ago

Hi @Fleick, Thanks for reporting this, I'll be working on this library soon after the release of the Elastic stack 7.11 and I'll take a look at this issue.

Cheers!

Hey @picandocodigo, is there already an approximate schedule when to expect the processing? :)