Tell me who can work with Spring data mongoDB
How to do this with a mongo driver?
This is the mongo shell:
db.stores.find( { $text: { $search: "java coffee shop" } }, { score: { $meta: "textScore" } } ).sort( { score: { $meta: "textScore" } } ) That's what I tried to do, but this is not exactly what you need!
This is Kotlin mongo driver:
override fun getSearchedFiles(searchQuery: String, pageNumber: Long, pageSize: Long, direction: Sort.Direction, sortColumn: String): MutableList<SystemFile> { val matching = TextCriteria.forDefaultLanguage().matching(searchQuery) val match = MatchOperation(matching) val sort = SortOperation(Sort(direction, sortColumn)) val skip = SkipOperation((pageNumber * pageSize)) val limit = LimitOperation(pageSize) val aggregation = Aggregation .newAggregation(match, skip, limit) .withOptions(Aggregation.newAggregationOptions().allowDiskUse(true).build()) val mappedResults = template.aggregate(aggregation, "files", SystemFile::class.java).mappedResults return mappedResults }