Modify Solr query to find collections with submit permissions in searches with spaces

This commit is contained in:
Toni Prieto
2024-10-27 09:40:05 +01:00
parent 1b16a55335
commit 425dc1556e
2 changed files with 19 additions and 2 deletions

View File

@@ -1021,7 +1021,8 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
if (StringUtils.isNotBlank(q)) {
StringBuilder buildQuery = new StringBuilder();
String escapedQuery = ClientUtils.escapeQueryChars(q);
buildQuery.append("(").append(escapedQuery).append(" OR ").append(escapedQuery).append("*").append(")");
buildQuery.append("(").append(escapedQuery).append(" OR dc.title_sort:*")
.append(escapedQuery).append("*").append(")");
discoverQuery.setQuery(buildQuery.toString());
}
DiscoverResult resp = searchService.search(context, discoverQuery);

View File

@@ -698,6 +698,10 @@ public class CollectionRestRepositoryIT extends AbstractControllerIntegrationTes
.withName("Testing autocomplete in submission")
.withSubmitterGroup(eperson2)
.build();
Collection col5 = CollectionBuilder.createCollection(context, child2)
.withName("Colección de prueba")
.withSubmitterGroup(eperson2)
.build();
context.restoreAuthSystemState();
String tokenEPerson = getAuthToken(eperson.getEmail(), password);
@@ -741,7 +745,19 @@ public class CollectionRestRepositoryIT extends AbstractControllerIntegrationTes
getClient(tokenEPerson2).perform(get("/api/core/collections/search/findSubmitAuthorized")
.param("query", "testing auto"))
.andExpect(status().isOk())
.andExpect(jsonPath("$.page.totalElements", is(0)));
.andExpect(jsonPath("$._embedded.collections", Matchers.contains(
CollectionMatcher.matchProperties(col4.getName(), col4.getID(), col4.getHandle())
)))
.andExpect(jsonPath("$.page.totalElements", is(1)));
// Diacritics test
getClient(tokenEPerson2).perform(get("/api/core/collections/search/findSubmitAuthorized")
.param("query", "coléccion de"))
.andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.collections", Matchers.contains(
CollectionMatcher.matchProperties(col5.getName(), col5.getID(), col5.getHandle())
)))
.andExpect(jsonPath("$.page.totalElements", is(1)));
String tokenAdmin = getAuthToken(admin.getEmail(), password);
getClient(tokenAdmin).perform(get("/api/core/collections/search/findSubmitAuthorized")