-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MSEARCH-784] add bibframe authority index
- Loading branch information
Aleksei Pronichev
committed
Jun 26, 2024
1 parent
705e6e8
commit afc0e7c
Showing
27 changed files
with
537 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...va/org/folio/search/service/setter/bibframe/authority/BibframeAuthorityLccnProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.folio.search.service.setter.bibframe.authority; | ||
|
||
import static java.util.stream.Collectors.toCollection; | ||
import static org.folio.search.domain.dto.BibframeAuthorityIdentifiersInner.TypeEnum.LCCN; | ||
|
||
import java.util.Collections; | ||
import java.util.LinkedHashSet; | ||
import java.util.Objects; | ||
import java.util.Optional; | ||
import java.util.Set; | ||
import lombok.RequiredArgsConstructor; | ||
import org.folio.search.domain.dto.BibframeAuthority; | ||
import org.folio.search.domain.dto.BibframeAuthorityIdentifiersInner; | ||
import org.folio.search.service.lccn.LccnNormalizer; | ||
import org.folio.search.service.setter.FieldProcessor; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class BibframeAuthorityLccnProcessor implements FieldProcessor<BibframeAuthority, Set<String>> { | ||
|
||
private final LccnNormalizer lccnNormalizer; | ||
|
||
@Override | ||
public Set<String> getFieldValue(BibframeAuthority bibframe) { | ||
return Optional.of(bibframe) | ||
.map(BibframeAuthority::getIdentifiers) | ||
.orElseGet(Collections::emptyList) | ||
.stream() | ||
.filter(i -> LCCN.equals(i.getType())) | ||
.map(BibframeAuthorityIdentifiersInner::getValue) | ||
.filter(Objects::nonNull) | ||
.map(lccnNormalizer) | ||
.flatMap(Optional::stream) | ||
.collect(toCollection(LinkedHashSet::new)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
src/main/resources/elasticsearch/index/bibframe-authority.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
{ | ||
"index": { | ||
"number_of_shards": 4, | ||
"number_of_replicas": 2, | ||
"refresh_interval": "1s", | ||
"codec": "best_compression", | ||
"mapping.total_fields.limit": 1000 | ||
}, | ||
"analysis": { | ||
"filter": { | ||
"folio_word_delimiter_graph": { | ||
"type": "word_delimiter_graph", | ||
"catenate_words": true | ||
} | ||
}, | ||
"normalizer": { | ||
"keyword_lowercase": { | ||
"filter": [ | ||
"lowercase", | ||
"trim" | ||
], | ||
"type": "custom" | ||
}, | ||
"keyword_uppercase": { | ||
"filter": [ | ||
"uppercase", | ||
"trim" | ||
], | ||
"type": "custom" | ||
}, | ||
"keyword_trimmed": { | ||
"filter": [ | ||
"trim" | ||
], | ||
"type": "custom" | ||
} | ||
}, | ||
"analyzer": { | ||
"source_analyzer": { | ||
"tokenizer": "icu_tokenizer", | ||
"filter": [ | ||
"folio_word_delimiter_graph", | ||
"icu_folding" | ||
], | ||
"char_filter": [ | ||
"and_char_replacement" | ||
], | ||
"type": "custom" | ||
}, | ||
"whitespace_lowercase_analyzer": { | ||
"tokenizer": "whitespace", | ||
"filter": [ | ||
"lowercase", | ||
"icu_folding" | ||
], | ||
"type": "custom" | ||
} | ||
}, | ||
"tokenizers": { }, | ||
"char_filter": { | ||
"and_char_replacement": { | ||
"type": "pattern_replace", | ||
"pattern": " & ", | ||
"replacement": " and " | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"name": "bibframe-authority", | ||
"eventBodyJavaClass": "org.folio.search.domain.dto.BibframeAuthority", | ||
"reindexSupported": false, | ||
"fields": { | ||
"id": { | ||
"index": "keyword" | ||
}, | ||
"label": { | ||
"index": "standard" | ||
}, | ||
"type": { | ||
"index": "keyword" | ||
}, | ||
"identifiers": { | ||
"type": "object", | ||
"properties": { | ||
"value": { | ||
"index": "whitespace" | ||
}, | ||
"type": { | ||
"index": "whitespace" | ||
} | ||
} | ||
} | ||
}, | ||
"searchFields": { | ||
"lccn": { | ||
"type": "search", | ||
"index": "keyword", | ||
"processor": "bibframeAuthorityLccnProcessor" | ||
} | ||
}, | ||
"indexMappings": { } | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/resources/swagger.api/examples/result/bibframeSearchAuthorityResult.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
value: | ||
searchQuery: "query string" | ||
content: | ||
- id: "1" | ||
label: "Label Value" | ||
type: "Person" | ||
identifiers: | ||
- value: "sh85121033" | ||
type: "LCCN" | ||
pageNumber: 0 | ||
totalPages: 3 | ||
totalRecords: 27 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/main/resources/swagger.api/paths/search-bibframe/search-bibframe-authorities.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
get: | ||
operationId: searchBibframeAuthorities | ||
summary: Search Bibframe Authorities | ||
description: Get a list of bibframe authorities records for CQL query | ||
tags: | ||
- search | ||
parameters: | ||
- $ref: '../../parameters/x-okapi-tenant-header.yaml' | ||
- $ref: '../../parameters/cql-query.yaml' | ||
- $ref: '../../parameters/bibframe-limit-param.yaml' | ||
- $ref: '../../parameters/offset-param.yaml' | ||
responses: | ||
'200': | ||
description: 'Bibframe authorities search result' | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '../../schemas/response/bibframeSearchAuthorityResult.yaml' | ||
examples: | ||
searchResult: | ||
$ref: '../../examples/result/bibframeSearchAuthorityResult.yaml' | ||
'400': | ||
$ref: '../../responses/badRequestResponse.yaml' | ||
'500': | ||
$ref: '../../responses/internalServerErrorResponse.yaml' |
25 changes: 25 additions & 0 deletions
25
src/main/resources/swagger.api/schemas/dto/bibframe/bibframeAuthority.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
description: "Bibframe authority search dto, contains Authority and Identifiers" | ||
type: "object" | ||
properties: | ||
id: | ||
description: "The Linked Data ID of an Authority" | ||
type: "string" | ||
label: | ||
description: "Value of Label" | ||
type: "string" | ||
type: | ||
type: "string" | ||
identifiers: | ||
type: "array" | ||
description: "Authority identifier array" | ||
items: | ||
properties: | ||
value: | ||
type: "string" | ||
description: "Value of Identifier" | ||
type: | ||
type: "string" | ||
enum: | ||
- "LCCN" | ||
required: | ||
- "id" |
20 changes: 20 additions & 0 deletions
20
src/main/resources/swagger.api/schemas/response/bibframeSearchAuthorityResult.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
description: "Bibframe authority search result response" | ||
type: "object" | ||
properties: | ||
searchQuery: | ||
type: "string" | ||
description: "Initial search query" | ||
content: | ||
type: "array" | ||
description: "List of bibframe authority records found" | ||
items: | ||
$ref: "../../schemas/dto/bibframe/bibframeAuthority.yaml" | ||
pageNumber: | ||
type: "integer" | ||
description: "Current results page number, 0 by default" | ||
totalPages: | ||
type: "integer" | ||
description: "Total pages count" | ||
totalRecords: | ||
type: "integer" | ||
description: "Total results count" |
Oops, something went wrong.