currently, we have our Mongo servers running at Atlas and as a feature request, we must implement full-text search in our service, which uses Morphia, and this feature will affect one of our mapped classes. Our project uses yet Morphia 1.6.1.
Atlas provides a command that is not natively supported by Mongo, but in our case simplifies a lot our use-case (we don't have, for example, to index all our documents on Elastic Search).
By looking at the AggregationPipeline interface of Morphia 1.6.1 or the Javadocs of the Aggregation interface in the last version (2.3-SNAPSHOT), we don't see how to achieve this, and we were wondering if there is some way, like pass a native object to one of the stages of the pipeline.
There is any workaround for this?.
Thanks in advance.
The best recommendation I can make is the newly released Java builders for Atlas Search.
They simplify a lot of the work. The example they provide for search a title field looks a lot better than the raw aggregation pipeline equivalent for Java.
New builder syntax:
Bson textSearch = Aggregates.search(
SearchOperator.text(
SearchPath.fieldPath("title"), "Future"));
Legacy, without builder syntax:
FindIterable<Document> result = collection.aggregate(Arrays.asList(new Document("$search",
new Document("text",
new Document("query", "Future")
.append("path", "title"))))