Skip to content

Commit

Permalink
MSEARCH-844: Linked Data Hub index introduced instead of not used LD …
Browse files Browse the repository at this point in the history
…Authority index
  • Loading branch information
PBobylev committed Oct 10, 2024
1 parent f2763cf commit ce30103
Show file tree
Hide file tree
Showing 35 changed files with 207 additions and 264 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
* Create computed field for sorting and filtering Date 1 ([MSEARCH-806](https://folio-org.atlassian.net/browse/MSEARCH-806))
* Support filters for subject source and type on subject browse ([MSEARCH-805](https://folio-org.atlassian.net/browse/MSEARCH-805))
* Implement new re-index flow for instance records ([MSEARCH-793](https://folio-org.atlassian.net/issues/MSEARCH-793), [MSEARCH-794](https://folio-org.atlassian.net/issues/MSEARCH-794), [MSEARCH-796](https://folio-org.atlassian.net/issues/MSEARCH-796), [MSEARCH-797](https://folio-org.atlassian.net/issues/MSEARCH-797), [MSEARCH-798](https://folio-org.atlassian.net/issues/MSEARCH-798), [MSEARCH-799](https://folio-org.atlassian.net/issues/MSEARCH-799), [MSEARCH-800](https://folio-org.atlassian.net/issues/MSEARCH-800), [MSEARCH-801](https://folio-org.atlassian.net/issues/MSEARCH-801), [MSEARCH-802](https://folio-org.atlassian.net/issues/MSEARCH-802))
* Implement Linked Data HUB index and search API ([MSEARCH-844](https://folio-org.atlassian.net/browse/MSEARCH-844))

### Bug fixes
* Do not delete kafka topics if collection topic is enabled ([MSEARCH-725](https://folio-org.atlassian.net/browse/MSEARCH-725))
Expand Down
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,11 +328,11 @@ x-okapi-token: [JWT_TOKEN]
```

* `resourceName` parameter is optional and equal to `instance` by default. Possible values: `instance`, `authority`, `location`,
`linked-data-instance`, `linked-data-work`, `linked-data-authority`. Please note that `location` reindex is synchronous.
`linked-data-instance`, `linked-data-work`, `linked-data-hub`. Please note that `location` reindex is synchronous.
* `recreateIndex` parameter is optional and equal to `false` by default. If it is equal to `true` then mod-search
will drop existing indices for tenant and resource, creating them again. Executing request with this parameter
equal to `true` in query will erase all the tenant data in mod-search.
* Please note that for `linked-data-instance`, `linked-data-work` and `linked-data-authority` resources the endpoint is used only for index recreation
* Please note that for `linked-data-instance`, `linked-data-work` and `linked-data-hub` resources the endpoint is used only for index recreation
purpose and actual reindex operation is triggered through mod-linked-data.

### Monitoring reindex process
Expand Down Expand Up @@ -518,16 +518,16 @@ Consortium feature on module enable is defined by 'centralTenantId' tenant param

### Search API

| METHOD | URL | DESCRIPTION |
|:-------|:----------------------------------|:-------------------------------------------------------------------------------------|
| GET | `/search/instances` | Search by instances and to this instance items and holding-records |
| GET | `/search/authorities` | Search by authority records |
| GET | `/search/linked-data/instances` | Search linked data graph instance resource descriptions |
| GET | `/search/linked-data/works` | Search linked data graph work resource descriptions |
| GET | `/search/linked-data/authorities` | Search linked data graph authority resource descriptions |
| GET | `/search/{recordType}/facets` | Get facets where recordType could be: instances, authorities, contributors, subjects |
| GET | ~~`/search/instances/ids`~~ | (DEPRECATED) Stream instance ids as JSON or plain text |
| GET | ~~`/search/holdings/ids`~~ | (DEPRECATED) Stream holding record ids as JSON or plain text |
| METHOD | URL | DESCRIPTION |
|:-------|:--------------------------------|:-------------------------------------------------------------------------------------|
| GET | `/search/instances` | Search by instances and to this instance items and holding-records |
| GET | `/search/authorities` | Search by authority records |
| GET | `/search/linked-data/instances` | Search linked data graph instance resource descriptions |
| GET | `/search/linked-data/works` | Search linked data graph work resource descriptions |
| GET | `/search/linked-data/hubs` | Search linked data graph hub resource descriptions |
| GET | `/search/{recordType}/facets` | Get facets where recordType could be: instances, authorities, contributors, subjects |
| GET | ~~`/search/instances/ids`~~ | (DEPRECATED) Stream instance ids as JSON or plain text |
| GET | ~~`/search/holdings/ids`~~ | (DEPRECATED) Stream holding record ids as JSON or plain text |

#### Searching and filtering

Expand Down
10 changes: 5 additions & 5 deletions descriptors/ModuleDescriptor-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@
"methods": [
"GET"
],
"pathPattern": "/search/linked-data/authorities",
"pathPattern": "/search/linked-data/hubs",
"permissionsRequired": [
"search.linked-data.authority.collection.get"
"search.linked-data.hub.collection.get"
],
"modulePermissions": [
"user-tenants.collection.get"
Expand Down Expand Up @@ -717,9 +717,9 @@
"description": "Searches linked data works by given query"
},
{
"permissionName": "search.linked-data.authority.collection.get",
"displayName": "Search - searches linked data authorities by given query",
"description": "Searches linked data authorities by given query"
"permissionName": "search.linked-data.hub.collection.get",
"displayName": "Search - searches linked data hubs by given query",
"description": "Searches linked data hubs by given query"
},
{
"permissionName": "browse.call-numbers.instances.collection.get",
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/org/folio/search/controller/SearchController.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import org.folio.search.domain.dto.AuthoritySearchResult;
import org.folio.search.domain.dto.Instance;
import org.folio.search.domain.dto.InstanceSearchResult;
import org.folio.search.domain.dto.LinkedDataAuthority;
import org.folio.search.domain.dto.LinkedDataAuthoritySearchResult;
import org.folio.search.domain.dto.LinkedDataHub;
import org.folio.search.domain.dto.LinkedDataHubSearchResult;
import org.folio.search.domain.dto.LinkedDataInstance;
import org.folio.search.domain.dto.LinkedDataInstanceSearchResult;
import org.folio.search.domain.dto.LinkedDataWork;
Expand Down Expand Up @@ -93,14 +93,14 @@ public ResponseEntity<LinkedDataWorkSearchResult> searchLinkedDataWorks(String t
}

@Override
public ResponseEntity<LinkedDataAuthoritySearchResult> searchLinkedDataAuthorities(String tenantId,
String query,
Integer limit,
Integer offset) {
public ResponseEntity<LinkedDataHubSearchResult> searchLinkedDataHubs(String tenantId,
String query,
Integer limit,
Integer offset) {
var searchRequest = CqlSearchRequest.of(
LinkedDataAuthority.class, tenantId, query, limit, offset, true);
LinkedDataHub.class, tenantId, query, limit, offset, true);
var result = searchService.search(searchRequest);
return ResponseEntity.ok(new LinkedDataAuthoritySearchResult()
return ResponseEntity.ok(new LinkedDataHubSearchResult()
.searchQuery(query)
.content(result.getRecords())
.pageNumber(divPlusOneIfRemainder(offset, limit))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class ResourceEventBatchInterceptor implements BatchInterceptor<String, R
Map.entry("inventory.library", ResourceType.LIBRARY),
Map.entry("linked-data.instance", ResourceType.LINKED_DATA_INSTANCE),
Map.entry("linked-data.work", ResourceType.LINKED_DATA_WORK),
Map.entry("linked-data.authority", ResourceType.LINKED_DATA_AUTHORITY)
Map.entry("linked-data.hub", ResourceType.LINKED_DATA_HUB)
);

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public enum ResourceType {
INSTITUTION("institution"),
ITEM("item"),
LIBRARY("library"),
LINKED_DATA_AUTHORITY("linked-data-authority"),
LINKED_DATA_HUB("linked-data-hub"),
LINKED_DATA_INSTANCE("linked-data-instance"),
LINKED_DATA_WORK("linked-data-work"),
LOCATION("location"),
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/folio/search/service/IndexService.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.folio.search.service;

import static java.lang.Boolean.TRUE;
import static org.folio.search.model.types.ResourceType.LINKED_DATA_AUTHORITY;
import static org.folio.search.model.types.ResourceType.LINKED_DATA_HUB;
import static org.folio.search.model.types.ResourceType.LINKED_DATA_INSTANCE;
import static org.folio.search.model.types.ResourceType.LINKED_DATA_WORK;
import static org.springframework.web.util.UriComponentsBuilder.fromUriString;
Expand Down Expand Up @@ -293,6 +293,6 @@ private static String normalizeResourceName(ResourceType resourceType) {
private boolean isLinkedDataResource(String resource) {
return LINKED_DATA_INSTANCE.getName().equals(resource)
|| LINKED_DATA_WORK.getName().equals(resource)
|| LINKED_DATA_AUTHORITY.getName().equals(resource);
|| LINKED_DATA_HUB.getName().equals(resource);
}
}

This file was deleted.

2 changes: 1 addition & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ folio:
group-id: ${folio.environment}-mod-search-location-type-group
linked-data:
concurrency: ${KAFKA_LINKED_DATA_CONCURRENCY:1}
topic-pattern: (${folio.environment}\.)(.*\.)linked-data\.(instance|work|authority)
topic-pattern: (${folio.environment}\.)(.*\.)linked-data\.(instance|work|hub)
group-id: ${folio.environment}-mod-search-linked-data-group
reindex-range-index:
concurrency: ${KAFKA_REINDEX_RANGE_INDEX_CONCURRENCY:2}
Expand Down
40 changes: 0 additions & 40 deletions src/main/resources/model/linked_data_authority.json

This file was deleted.

29 changes: 29 additions & 0 deletions src/main/resources/model/linked_data_hub.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "linked-data-hub",
"eventBodyJavaClass": "org.folio.search.domain.dto.LinkedDataHub",
"reindexSupported": true,
"fields": {
"id": {
"index": "keyword",
"searchAliases": [ "keyword" ]
},
"originalId": {
"index": "keyword",
"searchAliases": [ "keyword" ]
},
"tenantId": {
"index": "keyword_lowercase",
"showInResponse": [ "search" ],
"isTenant": true
},
"hubAAP": {
"searchAliases": [ "aap", "keyword" ],
"index": "multilang"
},
"title": {
"searchAliases": [ "keyword" ],
"index": "multilang"
}
},
"indexMappings": { }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
value:
searchQuery: "query string"
content:
- id: "1"
originalId: "d292aac1-6f82-4828-93ae-c1b5cde1318a"
hubAAP: "hub AAP"
title: "hub title"
pageNumber: 0
totalPages: 3
totalRecords: 27

This file was deleted.

4 changes: 2 additions & 2 deletions src/main/resources/swagger.api/mod-search.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ paths:
/search/linked-data/works:
$ref: 'paths/search-linked-data/search-linked-data-works.yaml'

/search/linked-data/authorities:
$ref: 'paths/search-linked-data/search-linked-data-authorities.yaml'
/search/linked-data/hubs:
$ref: 'paths/search-linked-data/search-linked-data-hubs.yaml'

/search/linked-data/instances:
$ref: 'paths/search-linked-data/search-linked-data-instances.yaml'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
get:
operationId: searchLinkedDataAuthorities
summary: Search Linked Data Authorities
description: Get a list of linked data authorities records for CQL query
operationId: searchLinkedDataHubs
summary: Search Linked Data Hubs
description: Get a list of linked data Hubs records for CQL query
tags:
- search
parameters:
Expand All @@ -11,14 +11,14 @@ get:
- $ref: '../../parameters/offset-param.yaml'
responses:
'200':
description: 'Linked data authorities search result'
description: 'Linked data Hubs search result'
content:
application/json:
schema:
$ref: '../../schemas/response/linkedDataAuthoritySearchResult.yaml'
$ref: '../../schemas/response/linkedDataHubSearchResult.yaml'
examples:
searchResult:
$ref: '../../examples/result/linkedDataSearchAuthorityResult.yaml'
$ref: '../../examples/result/linkedDataHubSearchResult.yaml'
'400':
$ref: '../../responses/badRequestResponse.yaml'
'500':
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
description: "Linked Data Hub search dto, contains Hub and Identifiers"
type: "object"
properties:
id:
description: "The Linked Data ID of an Hub"
type: "string"
originalId:
description: "Original RDF ID of an Hub"
type: "string"
tenantId:
description: "Tenant ID"
type: "string"
hubAAP:
description: "Hub AAP"
type: "string"
title:
description: "Hub Variant title"
type: "string"
required:
- "id"
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ properties:
- location
- linked-data-instance
- linked-data-work
- linked-data-authority
- linked-data-hub
indexSettings:
description: Index settings to apply for index
$ref: "../../schemas/entity/indexSettings.yaml"
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
description: "Linked data authority search result response"
description: "Linked data Hub search result response"
type: "object"
properties:
searchQuery:
type: "string"
description: "Initial search query"
content:
type: "array"
description: "List of linked data authority records found"
description: "List of linked data hub records found"
items:
$ref: "../../schemas/dto/linked-data/linkedDataAuthority.yaml"
$ref: "../../schemas/dto/linked-data/linkedDataHub.yaml"
pageNumber:
type: "integer"
description: "Current results page number, 0 by default"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void runReindex_positive_locations() throws Exception {
}

@ParameterizedTest
@EnumSource(value = ResourceType.class, names = {"LINKED_DATA_WORK", "LINKED_DATA_AUTHORITY"})
@EnumSource(value = ResourceType.class, names = {"LINKED_DATA_WORK", "LINKED_DATA_HUB"})
void runReindex_shouldRecreate_linkedDataResourcesIndexes(ResourceType resourceType) throws Exception {
var reindexRequest = new ReindexRequest()
.resourceName(ResourceNameEnum.valueOf(resourceType.name()))
Expand Down
Loading

0 comments on commit ce30103

Please sign in to comment.