diff --git a/NEWS.md b/NEWS.md index 4a5b86175..7440027dd 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,6 @@ ## v28.1.0 YYYY-mm-DD ### Breaking changes -* Description ([ISSUE](https://folio-org.atlassian.net/browse/ISSUE)) +* Drop CQL array support for `instance identifiers` field ([MODINVSTOR-1277](https://folio-org.atlassian.net/browse/MODINVSTOR-1277)) ### New APIs versions * Provides `API_NAME vX.Y` @@ -21,7 +21,7 @@ * Add item barcode right truncation search index ([MODINVSTOR-1292](https://folio-org.atlassian.net/browse/MODINVSTOR-1292)) ### Tech Dept -* Description ([ISSUE](https://folio-org.atlassian.net/browse/ISSUE)) +* Delete 6 unused instance database indexes ([MODINVSTOR-1277](https://folio-org.atlassian.net/browse/MODINVSTOR-1277)) ### Dependencies * Bump `LIB_NAME` from `OLD_VERSION` to `NEW_VERSION` diff --git a/src/main/java/org/folio/rest/impl/InstanceStorageApi.java b/src/main/java/org/folio/rest/impl/InstanceStorageApi.java index 6d711bd1b..a2ebbf069 100644 --- a/src/main/java/org/folio/rest/impl/InstanceStorageApi.java +++ b/src/main/java/org/folio/rest/impl/InstanceStorageApi.java @@ -24,7 +24,6 @@ import org.folio.rest.jaxrs.model.InstanceRelationship; import org.folio.rest.jaxrs.model.InstanceRelationships; import org.folio.rest.jaxrs.model.InstanceWithoutPubPeriod; -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; @@ -35,8 +34,6 @@ import org.folio.rest.persist.PostgresClient; import org.folio.rest.persist.cql.CQLWrapper; import org.folio.rest.support.EndpointFailureHandler; -import org.folio.rest.support.EndpointHandler; -import org.folio.rest.support.GetInstanceStorageInstanceResponse; import org.folio.rest.tools.messages.MessageConsts; import org.folio.rest.tools.messages.Messages; import org.folio.rest.tools.utils.TenantTool; @@ -45,7 +42,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 @@ -206,7 +202,7 @@ public void getInstanceStorageInstances(String totalRecords, int offset, int lim Handler> asyncResultHandler, Context vertxContext) { - fetchInstances(query, limit, offset, routingContext, okapiHeaders, asyncResultHandler, vertxContext); + fetchInstances(query, limit, offset, routingContext, okapiHeaders, vertxContext); } @Validate @@ -390,28 +386,13 @@ public void postInstanceStorageInstancesRetrieve(RetrieveDto entity, Handler> 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 okapiHeaders, - Handler> asyncResultHandler, Context vertxContext) { - if (PgUtil.checkOptimizedCQL(query, TITLE) != null) { - try { - PreparedCql preparedCql = handleCql(query, limit, offset); - PgUtil.getWithOptimizedSql(preparedCql.getTableName(), Instance.class, Instances.class, - TITLE, query, offset, limit, - okapiHeaders, vertxContext, GetInstanceStorageInstanceResponse.class, - EndpointHandler.handleInstances(asyncResultHandler)); - } catch (Exception e) { - log.error(e.getMessage(), e); - asyncResultHandler.handle(io.vertx.core.Future.succeededFuture( - GetInstanceStorageInstancesResponse.respond500WithTextPlain(e.getMessage()))); - } - return; - } new InstanceService(vertxContext, okapiHeaders) .streamGetInstances(INSTANCE_TABLE, query, offset, limit, null, "instances", 0, routingContext); } diff --git a/src/main/resources/templates/db_scripts/populateRmbInternalIndex.sql b/src/main/resources/templates/db_scripts/populateRmbInternalIndex.sql deleted file mode 100644 index c219d28fe..000000000 --- a/src/main/resources/templates/db_scripts/populateRmbInternalIndex.sql +++ /dev/null @@ -1,141 +0,0 @@ -DO $$ -DECLARE - n INT; -BEGIN - -- Only populate if table is empty - SELECT count(*) INTO n FROM ${myuniversity}_${mymodule}.rmb_internal_index; - IF n > 0 THEN - RETURN; - END IF; - CASE '${version}' -- previous module version taken from the /_/tenant POST module_from variable - WHEN '18.2.3', 'mod-inventory-storage-18.2.3', - '18.2.2', 'mod-inventory-storage-18.2.2', - '18.2.1', 'mod-inventory-storage-18.2.1' THEN - -- Edelweiss versions 18.2.1 - 18.2.3; earlier versions don't have left(..., 600) index truncation - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('alternative_title_type_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS alternative_title_type_name_idx_unique ON ${myuniversity}_${mymodule}.alternative_title_type (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('call_number_type_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS call_number_type_name_idx_unique ON ${myuniversity}_${mymodule}.call_number_type (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('classification_type_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS classification_type_name_idx_unique ON ${myuniversity}_${mymodule}.classification_type (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('contributor_name_type_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS contributor_name_type_name_idx_unique ON ${myuniversity}_${mymodule}.contributor_name_type (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('contributor_type_code_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS contributor_type_code_idx_unique ON ${myuniversity}_${mymodule}.contributor_type (lower(f_unaccent(jsonb->>''code'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('contributor_type_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS contributor_type_name_idx_unique ON ${myuniversity}_${mymodule}.contributor_type (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('electronic_access_relationship_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS electronic_access_relationship_name_idx_unique ON ${myuniversity}_${mymodule}.electronic_access_relationship (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('holdings_note_type_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS holdings_note_type_name_idx_unique ON ${myuniversity}_${mymodule}.holdings_note_type (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('holdings_record_hrid_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS holdings_record_hrid_idx_unique ON ${myuniversity}_${mymodule}.holdings_record (lower(f_unaccent(jsonb->>''hrid'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('holdings_type_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS holdings_type_name_idx_unique ON ${myuniversity}_${mymodule}.holdings_type (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('identifier_type_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS identifier_type_name_idx_unique ON ${myuniversity}_${mymodule}.identifier_type (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('ill_policy_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS ill_policy_name_idx_unique ON ${myuniversity}_${mymodule}.ill_policy (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_classifications_idx_gin', 'CREATE INDEX IF NOT EXISTS instance_classifications_idx_gin ON ${myuniversity}_${mymodule}.instance USING GIN ((lower(f_unaccent(jsonb->>''classifications''))) gin_trgm_ops)', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_contributors_idx', 'CREATE INDEX IF NOT EXISTS instance_contributors_idx ON ${myuniversity}_${mymodule}.instance (left(lower(f_unaccent(jsonb->>''contributors'')),600))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_contributors_idx_ft', 'CREATE INDEX IF NOT EXISTS instance_contributors_idx_ft ON ${myuniversity}_${mymodule}.instance USING GIN ( to_tsvector(''simple'', f_unaccent(jsonb->>''contributors'')) )', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_contributors_idx_gin', 'CREATE INDEX IF NOT EXISTS instance_contributors_idx_gin ON ${myuniversity}_${mymodule}.instance USING GIN ((lower(f_unaccent(jsonb->>''contributors''))) gin_trgm_ops)', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_format_code_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS instance_format_code_idx_unique ON ${myuniversity}_${mymodule}.instance_format (lower(f_unaccent(jsonb->>''code'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_format_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS instance_format_name_idx_unique ON ${myuniversity}_${mymodule}.instance_format (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_hrid_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS instance_hrid_idx_unique ON ${myuniversity}_${mymodule}.instance (lower(f_unaccent(jsonb->>''hrid'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_identifiers_idx_ft', 'CREATE INDEX IF NOT EXISTS instance_identifiers_idx_ft ON ${myuniversity}_${mymodule}.instance USING GIN ( to_tsvector(''simple'', f_unaccent(jsonb->>''identifiers'')) )', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_identifiers_idx_gin', 'CREATE INDEX IF NOT EXISTS instance_identifiers_idx_gin ON ${myuniversity}_${mymodule}.instance USING GIN ((lower(f_unaccent(jsonb->>''identifiers''))) gin_trgm_ops)', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_indexTitle_idx', 'CREATE INDEX IF NOT EXISTS instance_indexTitle_idx ON ${myuniversity}_${mymodule}.instance (left(lower(f_unaccent(jsonb->>''indexTitle'')),600))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_indexTitle_idx_gin', 'CREATE INDEX IF NOT EXISTS instance_indexTitle_idx_gin ON ${myuniversity}_${mymodule}.instance USING GIN ((lower(f_unaccent(jsonb->>''indexTitle''))) gin_trgm_ops)', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_keyword_idx_ft', 'CREATE INDEX IF NOT EXISTS instance_keyword_idx_ft ON ${myuniversity}_${mymodule}.instance USING GIN ( to_tsvector(''simple'', f_unaccent(concat_space_sql(instance.jsonb->>''title'' , concat_array_object_values(instance.jsonb->''contributors'',''name'') , concat_array_object_values(instance.jsonb->''identifiers'',''value'')))) )', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_languages_idx_ft', 'CREATE INDEX IF NOT EXISTS instance_languages_idx_ft ON ${myuniversity}_${mymodule}.instance USING GIN ( to_tsvector(''simple'', f_unaccent(jsonb->>''languages'')) )', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_note_type_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS instance_note_type_name_idx_unique ON ${myuniversity}_${mymodule}.instance_note_type (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_publication_idx', 'CREATE INDEX IF NOT EXISTS instance_publication_idx ON ${myuniversity}_${mymodule}.instance (left(lower(f_unaccent(jsonb->>''publication'')),600))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_relationship_type_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS instance_relationship_type_name_idx_unique ON ${myuniversity}_${mymodule}.instance_relationship_type (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_source_idx', 'CREATE INDEX IF NOT EXISTS instance_source_idx ON ${myuniversity}_${mymodule}.instance (left(lower(jsonb->>''source''),600))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_statisticalCodeIds_idx', 'CREATE INDEX IF NOT EXISTS instance_statisticalCodeIds_idx ON ${myuniversity}_${mymodule}.instance (left(lower(jsonb->>''statisticalCodeIds''),600))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_status_code_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS instance_status_code_idx_unique ON ${myuniversity}_${mymodule}.instance_status (lower(f_unaccent(jsonb->>''code'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_status_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS instance_status_name_idx_unique ON ${myuniversity}_${mymodule}.instance_status (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_subjects_idx_gin', 'CREATE INDEX IF NOT EXISTS instance_subjects_idx_gin ON ${myuniversity}_${mymodule}.instance USING GIN ((lower(f_unaccent(jsonb->>''subjects''))) gin_trgm_ops)', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_title_idx', 'CREATE INDEX IF NOT EXISTS instance_title_idx ON ${myuniversity}_${mymodule}.instance (left(lower(f_unaccent(jsonb->>''title'')),600))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_title_idx_ft', 'CREATE INDEX IF NOT EXISTS instance_title_idx_ft ON ${myuniversity}_${mymodule}.instance USING GIN ( to_tsvector(''simple'', f_unaccent(jsonb->>''title'')) )', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_title_idx_gin', 'CREATE INDEX IF NOT EXISTS instance_title_idx_gin ON ${myuniversity}_${mymodule}.instance USING GIN ((lower(f_unaccent(jsonb->>''title''))) gin_trgm_ops)', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_type_code_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS instance_type_code_idx_unique ON ${myuniversity}_${mymodule}.instance_type (lower(f_unaccent(jsonb->>''code'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_type_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS instance_type_name_idx_unique ON ${myuniversity}_${mymodule}.instance_type (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('item_barcode_idx', 'CREATE INDEX IF NOT EXISTS item_barcode_idx ON ${myuniversity}_${mymodule}.item (left(lower(f_unaccent(jsonb->>''barcode'')),600))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('item_barcode_idx_ft', 'CREATE INDEX IF NOT EXISTS item_barcode_idx_ft ON ${myuniversity}_${mymodule}.item USING GIN ( to_tsvector(''simple'', f_unaccent(jsonb->>''barcode'')) )', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('item_barcode_idx_gin', 'CREATE INDEX IF NOT EXISTS item_barcode_idx_gin ON ${myuniversity}_${mymodule}.item USING GIN ((lower(f_unaccent(jsonb->>''barcode''))) gin_trgm_ops)', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('item_damaged_status_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS item_damaged_status_name_idx_unique ON ${myuniversity}_${mymodule}.item_damaged_status (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('item_hrid_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS item_hrid_idx_unique ON ${myuniversity}_${mymodule}.item (lower(f_unaccent(jsonb->>''hrid'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('item_note_type_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS item_note_type_name_idx_unique ON ${myuniversity}_${mymodule}.item_note_type (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('item_status_name_idx', 'CREATE INDEX IF NOT EXISTS item_status_name_idx ON ${myuniversity}_${mymodule}.item (left(lower(f_unaccent(jsonb->''status''->>''name'')),600))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('item_status_name_idx_gin', 'CREATE INDEX IF NOT EXISTS item_status_name_idx_gin ON ${myuniversity}_${mymodule}.item USING GIN ((lower(f_unaccent(jsonb->''status''->>''name''))) gin_trgm_ops)', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('loan_type_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS loan_type_name_idx_unique ON ${myuniversity}_${mymodule}.loan_type (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('location_code_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS location_code_idx_unique ON ${myuniversity}_${mymodule}.location (lower(f_unaccent(jsonb->>''code'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('location_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS location_name_idx_unique ON ${myuniversity}_${mymodule}.location (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('loccampus_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS loccampus_name_idx_unique ON ${myuniversity}_${mymodule}.loccampus (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('locinstitution_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS locinstitution_name_idx_unique ON ${myuniversity}_${mymodule}.locinstitution (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('loclibrary_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS loclibrary_name_idx_unique ON ${myuniversity}_${mymodule}.loclibrary (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('material_type_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS material_type_name_idx_unique ON ${myuniversity}_${mymodule}.material_type (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('mode_of_issuance_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS mode_of_issuance_name_idx_unique ON ${myuniversity}_${mymodule}.mode_of_issuance (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('nature_of_content_term_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS nature_of_content_term_name_idx_unique ON ${myuniversity}_${mymodule}.nature_of_content_term (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('service_point_code_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS service_point_code_idx_unique ON ${myuniversity}_${mymodule}.service_point (lower(f_unaccent(jsonb->>''code'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('service_point_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS service_point_name_idx_unique ON ${myuniversity}_${mymodule}.service_point (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('service_point_user_userId_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS service_point_user_userId_idx_unique ON ${myuniversity}_${mymodule}.service_point_user (lower(f_unaccent(jsonb->>''userId'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('statistical_code_code_statisticalCodeTypeId_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS statistical_code_code_statisticalCodeTypeId_idx_unique ON ${myuniversity}_${mymodule}.statistical_code (lower(f_unaccent(jsonb->>''code'')) , lower(f_unaccent(jsonb->>''statisticalCodeTypeId'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('statistical_code_type_code_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS statistical_code_type_code_idx_unique ON ${myuniversity}_${mymodule}.statistical_code_type (lower(f_unaccent(jsonb->>''code'')))', false); - WHEN '19.0.0', 'mod-inventory-storage-19.0.0', - '19.1.0', 'mod-inventory-storage-19.1.0' THEN - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('alternative_title_type_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS alternative_title_type_name_idx_unique ON ${myuniversity}_${mymodule}.alternative_title_type (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('call_number_type_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS call_number_type_name_idx_unique ON ${myuniversity}_${mymodule}.call_number_type (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('classification_type_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS classification_type_name_idx_unique ON ${myuniversity}_${mymodule}.classification_type (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('contributor_name_type_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS contributor_name_type_name_idx_unique ON ${myuniversity}_${mymodule}.contributor_name_type (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('contributor_type_code_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS contributor_type_code_idx_unique ON ${myuniversity}_${mymodule}.contributor_type (lower(f_unaccent(jsonb->>''code'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('contributor_type_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS contributor_type_name_idx_unique ON ${myuniversity}_${mymodule}.contributor_type (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('electronic_access_relationship_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS electronic_access_relationship_name_idx_unique ON ${myuniversity}_${mymodule}.electronic_access_relationship (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('holdings_note_type_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS holdings_note_type_name_idx_unique ON ${myuniversity}_${mymodule}.holdings_note_type (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('holdings_record_callNumber_idx', 'CREATE INDEX IF NOT EXISTS holdings_record_callNumber_idx ON ${myuniversity}_${mymodule}.holdings_record (left(lower(jsonb->>''callNumber''),600))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('holdings_record_hrid_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS holdings_record_hrid_idx_unique ON ${myuniversity}_${mymodule}.holdings_record (lower(f_unaccent(jsonb->>''hrid'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('holdings_type_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS holdings_type_name_idx_unique ON ${myuniversity}_${mymodule}.holdings_type (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('identifier_type_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS identifier_type_name_idx_unique ON ${myuniversity}_${mymodule}.identifier_type (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('ill_policy_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS ill_policy_name_idx_unique ON ${myuniversity}_${mymodule}.ill_policy (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_classifications_idx_gin', 'CREATE INDEX IF NOT EXISTS instance_classifications_idx_gin ON ${myuniversity}_${mymodule}.instance USING GIN ((lower(f_unaccent(jsonb->>''classifications''))) gin_trgm_ops)', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_contributors_idx', 'CREATE INDEX IF NOT EXISTS instance_contributors_idx ON ${myuniversity}_${mymodule}.instance (left(lower(f_unaccent(jsonb->>''contributors'')),600))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_contributors_idx_ft', 'CREATE INDEX IF NOT EXISTS instance_contributors_idx_ft ON ${myuniversity}_${mymodule}.instance USING GIN ( to_tsvector(''simple'', f_unaccent(jsonb->>''contributors'')) )', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_contributors_idx_gin', 'CREATE INDEX IF NOT EXISTS instance_contributors_idx_gin ON ${myuniversity}_${mymodule}.instance USING GIN ((lower(f_unaccent(jsonb->>''contributors''))) gin_trgm_ops)', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_format_code_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS instance_format_code_idx_unique ON ${myuniversity}_${mymodule}.instance_format (lower(f_unaccent(jsonb->>''code'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_format_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS instance_format_name_idx_unique ON ${myuniversity}_${mymodule}.instance_format (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_hrid_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS instance_hrid_idx_unique ON ${myuniversity}_${mymodule}.instance (lower(f_unaccent(jsonb->>''hrid'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_identifiers_idx_ft', 'CREATE INDEX IF NOT EXISTS instance_identifiers_idx_ft ON ${myuniversity}_${mymodule}.instance USING GIN ( to_tsvector(''simple'', f_unaccent(jsonb->>''identifiers'')) )', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_identifiers_idx_gin', 'CREATE INDEX IF NOT EXISTS instance_identifiers_idx_gin ON ${myuniversity}_${mymodule}.instance USING GIN ((lower(f_unaccent(jsonb->>''identifiers''))) gin_trgm_ops)', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_indexTitle_idx', 'CREATE INDEX IF NOT EXISTS instance_indexTitle_idx ON ${myuniversity}_${mymodule}.instance (left(lower(f_unaccent(jsonb->>''indexTitle'')),600))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_indexTitle_idx_gin', 'CREATE INDEX IF NOT EXISTS instance_indexTitle_idx_gin ON ${myuniversity}_${mymodule}.instance USING GIN ((lower(f_unaccent(jsonb->>''indexTitle''))) gin_trgm_ops)', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_languages_idx_ft', 'CREATE INDEX IF NOT EXISTS instance_languages_idx_ft ON ${myuniversity}_${mymodule}.instance USING GIN ( to_tsvector(''simple'', f_unaccent(jsonb->>''languages'')) )', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_note_type_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS instance_note_type_name_idx_unique ON ${myuniversity}_${mymodule}.instance_note_type (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_publication_idx', 'CREATE INDEX IF NOT EXISTS instance_publication_idx ON ${myuniversity}_${mymodule}.instance (left(lower(f_unaccent(jsonb->>''publication'')),600))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_relationship_type_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS instance_relationship_type_name_idx_unique ON ${myuniversity}_${mymodule}.instance_relationship_type (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_source_idx', 'CREATE INDEX IF NOT EXISTS instance_source_idx ON ${myuniversity}_${mymodule}.instance (left(lower(jsonb->>''source''),600))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_statisticalCodeIds_idx', 'CREATE INDEX IF NOT EXISTS instance_statisticalCodeIds_idx ON ${myuniversity}_${mymodule}.instance (left(lower(jsonb->>''statisticalCodeIds''),600))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_status_code_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS instance_status_code_idx_unique ON ${myuniversity}_${mymodule}.instance_status (lower(f_unaccent(jsonb->>''code'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_status_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS instance_status_name_idx_unique ON ${myuniversity}_${mymodule}.instance_status (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_subjects_idx_gin', 'CREATE INDEX IF NOT EXISTS instance_subjects_idx_gin ON ${myuniversity}_${mymodule}.instance USING GIN ((lower(f_unaccent(jsonb->>''subjects''))) gin_trgm_ops)', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_title_idx', 'CREATE INDEX IF NOT EXISTS instance_title_idx ON ${myuniversity}_${mymodule}.instance (left(lower(f_unaccent(jsonb->>''title'')),600))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_title_idx_ft', 'CREATE INDEX IF NOT EXISTS instance_title_idx_ft ON ${myuniversity}_${mymodule}.instance USING GIN ( to_tsvector(''simple'', f_unaccent(jsonb->>''title'')) )', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_title_idx_gin', 'CREATE INDEX IF NOT EXISTS instance_title_idx_gin ON ${myuniversity}_${mymodule}.instance USING GIN ((lower(f_unaccent(jsonb->>''title''))) gin_trgm_ops)', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_type_code_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS instance_type_code_idx_unique ON ${myuniversity}_${mymodule}.instance_type (lower(f_unaccent(jsonb->>''code'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('instance_type_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS instance_type_name_idx_unique ON ${myuniversity}_${mymodule}.instance_type (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('item_accessionNumber_idx', 'CREATE INDEX IF NOT EXISTS item_accessionNumber_idx ON ${myuniversity}_${mymodule}.item (left(lower(jsonb->>''accessionNumber''),600))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('item_barcode_idx', 'CREATE INDEX IF NOT EXISTS item_barcode_idx ON ${myuniversity}_${mymodule}.item (left(lower(f_unaccent(jsonb->>''barcode'')),600))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('item_barcode_idx_ft', 'CREATE INDEX IF NOT EXISTS item_barcode_idx_ft ON ${myuniversity}_${mymodule}.item USING GIN ( to_tsvector(''simple'', f_unaccent(jsonb->>''barcode'')) )', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('item_barcode_idx_gin', 'CREATE INDEX IF NOT EXISTS item_barcode_idx_gin ON ${myuniversity}_${mymodule}.item USING GIN ((lower(f_unaccent(jsonb->>''barcode''))) gin_trgm_ops)', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('item_damaged_status_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS item_damaged_status_name_idx_unique ON ${myuniversity}_${mymodule}.item_damaged_status (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('item_hrid_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS item_hrid_idx_unique ON ${myuniversity}_${mymodule}.item (lower(f_unaccent(jsonb->>''hrid'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('item_note_type_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS item_note_type_name_idx_unique ON ${myuniversity}_${mymodule}.item_note_type (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('item_status_name_idx', 'CREATE INDEX IF NOT EXISTS item_status_name_idx ON ${myuniversity}_${mymodule}.item (left(lower(f_unaccent(jsonb->''status''->>''name'')),600))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('item_status_name_idx_gin', 'CREATE INDEX IF NOT EXISTS item_status_name_idx_gin ON ${myuniversity}_${mymodule}.item USING GIN ((lower(f_unaccent(jsonb->''status''->>''name''))) gin_trgm_ops)', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('loan_type_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS loan_type_name_idx_unique ON ${myuniversity}_${mymodule}.loan_type (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('location_code_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS location_code_idx_unique ON ${myuniversity}_${mymodule}.location (lower(f_unaccent(jsonb->>''code'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('location_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS location_name_idx_unique ON ${myuniversity}_${mymodule}.location (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('loccampus_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS loccampus_name_idx_unique ON ${myuniversity}_${mymodule}.loccampus (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('locinstitution_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS locinstitution_name_idx_unique ON ${myuniversity}_${mymodule}.locinstitution (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('loclibrary_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS loclibrary_name_idx_unique ON ${myuniversity}_${mymodule}.loclibrary (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('material_type_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS material_type_name_idx_unique ON ${myuniversity}_${mymodule}.material_type (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('mode_of_issuance_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS mode_of_issuance_name_idx_unique ON ${myuniversity}_${mymodule}.mode_of_issuance (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('nature_of_content_term_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS nature_of_content_term_name_idx_unique ON ${myuniversity}_${mymodule}.nature_of_content_term (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('service_point_code_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS service_point_code_idx_unique ON ${myuniversity}_${mymodule}.service_point (lower(f_unaccent(jsonb->>''code'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('service_point_name_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS service_point_name_idx_unique ON ${myuniversity}_${mymodule}.service_point (lower(f_unaccent(jsonb->>''name'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('service_point_user_userId_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS service_point_user_userId_idx_unique ON ${myuniversity}_${mymodule}.service_point_user (lower(f_unaccent(jsonb->>''userId'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('statistical_code_code_statisticalCodeTypeId_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS statistical_code_code_statisticalCodeTypeId_idx_unique ON ${myuniversity}_${mymodule}.statistical_code (lower(f_unaccent(jsonb->>''code'')) , lower(f_unaccent(jsonb->>''statisticalCodeTypeId'')))', false); - INSERT INTO ${myuniversity}_${mymodule}.rmb_internal_index VALUES ('statistical_code_type_code_idx_unique', 'CREATE UNIQUE INDEX IF NOT EXISTS statistical_code_type_code_idx_unique ON ${myuniversity}_${mymodule}.statistical_code_type (lower(f_unaccent(jsonb->>''code'')))', false); - ELSE - -- nothing to do, this results in rebuilding all indexes because we haven't investigated which indexes are exactly the same - END CASE; -END $$; diff --git a/src/main/resources/templates/db_scripts/schema.json b/src/main/resources/templates/db_scripts/schema.json index f92d732c5..a80c0705b 100644 --- a/src/main/resources/templates/db_scripts/schema.json +++ b/src/main/resources/templates/db_scripts/schema.json @@ -387,7 +387,7 @@ "ginIndex": [ { "fieldName": "identifiers", - "tOps": "ADD", + "tOps": "DELETE", "caseSensitive": false, "removeAccents": true } @@ -401,13 +401,13 @@ }, { "fieldName": "indexTitle", - "tOps": "ADD", + "tOps": "DELETE", "caseSensitive": false, "removeAccents": true }, { "fieldName": "title", - "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" @@ -928,11 +929,6 @@ "snippetPath": "setPreviouslyHeldDefault.sql", "fromModuleVersion": "20.2.0" }, - { - "run": "before", - "snippetPath": "populateRmbInternalIndex.sql", - "fromModuleVersion": "19.1.1" - }, { "run": "before", "snippetPath": "createIsbnFunctions.sql", diff --git a/src/test/java/org/folio/rest/api/InstanceStorageTest.java b/src/test/java/org/folio/rest/api/InstanceStorageTest.java index 286130989..9c1992d55 100644 --- a/src/test/java/org/folio/rest/api/InstanceStorageTest.java +++ b/src/test/java/org/folio/rest/api/InstanceStorageTest.java @@ -1223,21 +1223,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();