Skip to content

Commit

Permalink
Merge pull request #238 from europeana/EA-3419_fix_sorting
Browse files Browse the repository at this point in the history
append soring by id as second criteria #EA-3419
  • Loading branch information
gsergiu authored Aug 16, 2023
2 parents 14cf6cb + 4998f91 commit 74bd3d4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import eu.europeana.set.mongo.model.internal.GeneratedUserSetIdImpl;
import eu.europeana.set.mongo.model.internal.PersistentUserSet;
import eu.europeana.set.mongo.model.PersistentUserSetImpl;
import eu.europeana.set.mongo.model.UserSetMongoConstants;
import eu.europeana.set.web.model.WebUserSetImpl;

public class PersistentUserSetDaoImpl <E extends PersistentUserSet, T extends Serializable>
Expand Down Expand Up @@ -50,7 +51,7 @@ public long generateNextUserSetId(String provider) {
synchronized (syncObj) {

Query<GeneratedUserSetIdImpl> q = getDatastore().createQuery(GeneratedUserSetIdImpl.class);
q.filter("_id", provider);
q.filter(UserSetMongoConstants.MONGO_ID, provider);

UpdateOperations<GeneratedUserSetIdImpl> uOps = getDatastore()
.createUpdateOperations(GeneratedUserSetIdImpl.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,8 @@ private void setOrder(Query<PersistentUserSet> mongoQuery, UserSetQuery query) {
// check the score sort first (it can only be in desc order)
if (sortField.contains(WebUserSetFields.TEXT_SCORE_SORT)) {
mongoQuery.order(Meta.textScore());
mongoQuery.order(Sort.ascending(UserSetMongoConstants.MONGO_ID));

} else {
if (!sortField.contains(" ")) {
mongoQuery.order(Sort.ascending(sortField));
Expand Down

0 comments on commit 74bd3d4

Please sign in to comment.