Best method to search text in a library

In order to search a title or an author in a bookstore or a library which one is the best ? The aggregation framework $text or just using db.collection.find( { $text: { $search: “title” } } )

Thanks a lot

Hi @damon634

Both essentially use an text index on the field, the aggregation framework is a helper wrapper (the $text operator) to use that index within an aggregation. Either may be best depending on your use case and needs. If it is a simple once off query it is possible that the MQL find would be better, if it is where you might be doing additional processing and adding/modifying the output fields then the Aggregation Framework might be better.

Both are equally good and use the same underlying mechanisms so essentially it’s whatever is better for your application and your specific requirement for the search.

Kindest regards,
Eoin