mongodb-odm icon indicating copy to clipboard operation
mongodb-odm copied to clipboard

Aggregation with $text match() is not possible on documents with discriminator map set

Open mposchl opened this issue 2 years ago • 1 comments

I wonder why it is not possible to match text index in documents, that have discriminator map set. ODM always prepends this discriminator map (via the filters) to the query and when you add a match stage in the pipeline, it always fails within the getAggregation() call as the $text stage has to be the first pipeline. Is this by design, is there some workaround or is it a bug?

mposchl avatar Aug 25 '22 13:08 mposchl

From the top of my head it could have been done by an accident: we needed to add filter for the discriminator map and nobody thought about $text restrictions. As a proof of concept you could try forcing automatic discriminator-map-filter to be put as a second stage if $text was used (and only then). Using such approach we will not break any working functionality. If it works then cool, if not we can work from there. :)

malarzm avatar Aug 25 '22 20:08 malarzm