We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hello,
First of all here is my dependency : "org.springframework.boot:spring-boot-starter-data-mongodb-reactive:2.6.1"
Here is my query:
// Pageable: Page request [number: 0, size 5, sort: updateTime: DESC] val textQuery = TextQuery.queryText(TextCriteria().matchingAny(search)) textQuery.with(pageable.sort) textQuery.sortByScore() textQuery.addCriteria(Account::owner isEqualTo owner) textQuery.skip(pageable.pageNumber.toLong()) textQuery.limit(pageable.pageSize) return template.find(textQuery.also { println(it) }, Account::class.java)
However when I print the query I get this:
Query: { "$text" : { "$search" : "ema"}, "owner" : { "$oid" : "1234567898"} }, Fields: { "score" : { "$meta" : "textScore"} }, Sort: { "score" : { "$meta" : "textScore"}, "updateTime" : -1 }
When looking at the source code you can clearly see that using sortByScore() ignores the order of sort and puts it in front of the Sort
@Override public Document getSortObject() { if (this.sortByScore) { Document sort = new Document(); sort.put(getScoreFieldName(), META_TEXT_SCORE); sort.putAll(super.getSortObject()); return sort; } return super.getSortObject(); }
the pageable sort is put at the end and therefore not doing anything. How can I sort by score and by the pageable ?
Possible fix:
@Override public Document getSortObject() { if (this.sortByScore) { Document sort = new Document(); sort.putAll(super.getSortObject()); sort.put(getScoreFieldName(), META_TEXT_SCORE); return sort; } return super.getSortObject(); }
The text was updated successfully, but these errors were encountered:
1131060
christophstrobl
Successfully merging a pull request may close this issue.
Hello,
First of all here is my dependency : "org.springframework.boot:spring-boot-starter-data-mongodb-reactive:2.6.1"
Here is my query:
However when I print the query I get this:
When looking at the source code you can clearly see that using sortByScore() ignores the order of sort and puts it in front of the Sort
the pageable sort is put at the end and therefore not doing anything. How can I sort by score and by the pageable ?
Possible fix:
The text was updated successfully, but these errors were encountered: