Closed ellnix closed 6 months ago
p Cat.search 'tob'
Even knowing the user defined the shared indexes everywhere, seems weird to me that they could have a polymorphic list of models while searching from one of the implementations in this case the Cat
one.
I like the approach of #341 where we have a clear entity that is responsible for doing that.
p Cat.search 'tob'
Even knowing the user defined the shared indexes everywhere, seems weird to me that they could have a polymorphic list of models while searching from one of the implementations in this case the
Cat
one.
Completely agreed, the only reason I suggested this version was if #341 was not good. Without either one of these two systems sharing an index between models seems like useless configuration (unless the meilisearch instance is also being used by something else).
Closing in favor of #341
Description The current implementation of shared indexes is deeply flawed, it:
ms_id
is"dog_#{id}"
will return every dog)Reproduce
These problems stem from the fact that the custom primary key cannot be used for lookup or to know the model name of the document in meilisearch.
Basic example
I would suggest instead of allowing the user to specify a primary key for a shared index, we instead allow them to pass a
shared_index: 'index_name'
option, which would add two non searchable fields in the meilisearch instance:_ms_model
and_ms_pk
. With this set up:Example: