'Can MongoDB query (A AND B) OR (C AND D) with any mix of text and structured clauses?

I'm developing a search app that allows users to combine arbitrary combinations of structured and unstructured clauses with Boolean logic in a graphical editor.

I have it working with an elasticsearch back-end but mongodb looks to be a no-go because of this:

A query can specify, at most, one $text expression.

That doesn't fly for me. I'd need to support (A OR B) AND (C OR D) where any of these clauses could be a text query e.g both A and D.

Is there any work-around? I'm a mongo noobie so wanted to check before I write it off as a choice of back-end.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source