MongoDB only allows one text-index per collection.
But you can use a text-index which spans multiple fields:
db.collection.ensureIndex( {
description: "text",
title: "text"
} );
That way you will get results when the phrase you are searching for is found in either. When this is not what you want, like when you have two search-queries which each return results from one of the fields but not the other, you have two options.
- use a multi-field text index, but discard the results which come from the wrong field on the application layer.
- extract one of the two fields to a different collection. The documents in that collection could either contain full copies, redacted copies or just the field you index and the
_id
of the original document.