Skip to content
New issue

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

MODINVSTOR-1277: Delete 6 unused instance database indexes #1101

Merged
merged 7 commits into from
Mar 3, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## v29.0.0 YYYY-mm-DD
### Breaking changes
* Upgrade to Java 21 ([MODINVSTOR-1364](https://folio-org.atlassian.net/browse/MODINVSTOR-1364))
* Drop CQL array support for `instance identifiers` field ([MODINVSTOR-1277](https://folio-org.atlassian.net/browse/MODINVSTOR-1277))

### New APIs versions
* Provides `inventory-hierarchy 0.6`
@@ -28,7 +29,7 @@
* Sort holdings by location name in instanceId query ([MODINVSTOR-1343](https://folio-org.atlassian.net/browse/MODINVSTOR-1343))

### Tech Dept
* Description ([ISSUE](https://folio-org.atlassian.net/browse/ISSUE))
* Delete 4 unused instance database indexes ([MODINVSTOR-1277](https://folio-org.atlassian.net/browse/MODINVSTOR-1277))

### Dependencies
* Bump `LIB_NAME` from `OLD_VERSION` to `NEW_VERSION`
21 changes: 2 additions & 19 deletions src/main/java/org/folio/rest/impl/InstanceStorageApi.java
Original file line number Diff line number Diff line change
@@ -22,7 +22,6 @@
import org.folio.rest.jaxrs.model.Instance;
import org.folio.rest.jaxrs.model.InstanceRelationship;
import org.folio.rest.jaxrs.model.InstanceRelationships;
import org.folio.rest.jaxrs.model.Instances;
import org.folio.rest.jaxrs.model.MarcJson;
import org.folio.rest.jaxrs.model.RetrieveDto;
import org.folio.rest.jaxrs.resource.InstanceStorage;
@@ -38,7 +37,6 @@

public class InstanceStorageApi implements InstanceStorage {
private static final Logger log = LogManager.getLogger();
private static final String TITLE = "title";
private final Messages messages = Messages.getInstance();

@Validate
@@ -198,8 +196,7 @@ public void getInstanceStorageInstances(String totalRecords, int offset, int lim
RoutingContext routingContext, Map<String, String> okapiHeaders,
Handler<AsyncResult<Response>> asyncResultHandler,
Context vertxContext) {

fetchInstances(query, limit, offset, routingContext, okapiHeaders, asyncResultHandler, vertxContext);
fetchInstances(query, limit, offset, routingContext, okapiHeaders, vertxContext);
}

@Validate
@@ -378,29 +375,15 @@ public void postInstanceStorageInstancesRetrieve(RetrieveDto entity,
Handler<AsyncResult<Response>> asyncResultHandler,
Context vertxContext) {
fetchInstances(entity.getQuery(), entity.getLimit(), entity.getOffset(),
routingContext, okapiHeaders, asyncResultHandler, vertxContext);
routingContext, okapiHeaders, vertxContext);
}

private void fetchInstances(String query, int limit, int offset,
RoutingContext routingContext,
Map<String, String> okapiHeaders,
Handler<AsyncResult<Response>> asyncResultHandler,
Context vertxContext) {
if (PgUtil.checkOptimizedCQL(query, TITLE) != null) {
try {
PgUtil.getWithOptimizedSql(INSTANCE_TABLE, Instance.class, Instances.class,
TITLE, query, offset, limit,
okapiHeaders, vertxContext, GetInstanceStorageInstancesResponse.class, asyncResultHandler);
} catch (Exception e) {
log.error(e.getMessage(), e);
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(
GetInstanceStorageInstancesResponse.respond500WithTextPlain(e.getMessage())));
}
return;
}
PgUtil.streamGet(INSTANCE_TABLE, Instance.class, query, offset, limit, null,
"instances", routingContext, okapiHeaders, vertxContext);

}

private static CQLWrapper createCqlWrapper(String query, int limit, int offset, String tableName)
141 changes: 0 additions & 141 deletions src/main/resources/templates/db_scripts/populateRmbInternalIndex.sql

This file was deleted.

12 changes: 4 additions & 8 deletions src/main/resources/templates/db_scripts/schema.json
Original file line number Diff line number Diff line change
@@ -387,7 +387,7 @@
"ginIndex": [
{
"fieldName": "identifiers",
"tOps": "ADD",
"tOps": "DELETE",
"caseSensitive": false,
"removeAccents": true
}
@@ -419,13 +419,13 @@
},
{
"fieldName": "contributors",
"tOps": "ADD",
"tOps": "DELETE",
"caseSensitive": false,
"removeAccents": true
},
{
"fieldName": "publication",
"tOps": "ADD",
"tOps": "DELETE",
"caseSensitive": false,
"removeAccents": true
},
@@ -451,6 +451,7 @@
"fullTextIndex": [
{
"fieldName": "identifiers",
"tOps": "DELETE",
"arraySubfield": "value",
"arrayModifiers": [
"identifierTypeId"
@@ -929,11 +930,6 @@
"snippetPath": "setPreviouslyHeldDefault.sql",
"fromModuleVersion": "20.2.0"
},
{
"run": "before",
"snippetPath": "populateRmbInternalIndex.sql",
"fromModuleVersion": "19.1.1"
},
{
"run": "before",
"snippetPath": "createIsbnFunctions.sql",
15 changes: 0 additions & 15 deletions src/test/java/org/folio/rest/api/InstanceStorageTest.java
Original file line number Diff line number Diff line change
@@ -1220,21 +1220,6 @@ public void canSearchForInstancesUsingSimilarQueryToUiLookAheadSearch() {
canSort("title=\"upr*\" or contributors=\"name\": \"upr*\" or identifiers=\"value\": \"upr*\"", "Uprooted");
}

@Test
public void arrayModifierfsIdentifiers1() {
canSort("identifiers = /@value 9781447294146", "Uprooted");
}

@Test
public void arrayModifierfsIdentifiers2() {
canSort("identifiers = /@identifierTypeId = " + UUID_ISBN + " 9781447294146", "Uprooted");
}

@Test
public void arrayModifierfsIdentifiers3() {
canSort("identifiers = /@identifierTypeId " + UUID_ASIN, "Nod");
}

@Test
public void canSearchWithoutSqlInjection() {
create5instances();