jbdemonte / mongoose-elasticsearch-xp

A mongoose plugin that indexes models into Elasticsearch 2 / 5 / 6 and 7
92 stars 34 forks source link

Support Mongoose Discriminators (?) #28

Open armand1m opened 6 years ago

armand1m commented 6 years ago

Hi, first of all, thanks for this package. Seems an interesting alternative to mongoosastic.

I'm currently having a trouble in mongoosastic (and I've actually opened this issue in their repo as well.)

I'm building a blogging platform. This blogging platform has 3 entities basic:

Publication is a mongoose schema with its own model. It has the primary keys needed for a publication such as: title, category, sources, etc.

InternalPublication and House are Publication discriminators. They live in the same collection in the database, but have different keys and are instantiated as different models in the application and have their schemas separated. These have some keys related to the publication itself.

The problem is, when I try to add the mongoosastic plugin to the Publication schema, it successfully handles InternalPublication and House post hooks, but when persisted to Elastic, it only persists the keys related to the Publication schema, and forget about all the fields related to InternalPublication or `House.

When I try to add the mongoosastic plugin to InternalPublication or House, it persists the only the schema keys, and forget about the discriminator parent.

I believe this has something to do with the fact that mongoosastic handles only schemas, and discriminators are defined at a model level. Does we have any ways of working with discriminators with this library?

jbdemonte commented 6 years ago

Hi,

Right now, I have no bandwidth to update this package (due to my job), but I plan to complete it. Unfortunately, I'm not able to give any deadline :/

But, If you want to submit MR, I'll be pleased to check it

borodayev commented 6 years ago

Hey guys, are there any changes about supporting discriminators?