-
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 19, 2024
1 parent
e90e766
commit 8ba03f0
Showing
26 changed files
with
455 additions
and
8 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
14 changes: 14 additions & 0 deletions
14
...a/org/folio/search/service/setter/bibframe/authority/BibframeAuthorityLabelProcessor.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,14 @@ | ||
package org.folio.search.service.setter.bibframe.authority; | ||
|
||
import org.folio.search.domain.dto.BibframeAuthority; | ||
import org.folio.search.service.setter.FieldProcessor; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class BibframeAuthorityLabelProcessor implements FieldProcessor<BibframeAuthority, String> { | ||
|
||
@Override | ||
public String getFieldValue(BibframeAuthority bibframe) { | ||
return bibframe.getLabel(); | ||
} | ||
} |
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)); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...va/org/folio/search/service/setter/bibframe/authority/BibframeAuthorityTypeProcessor.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,18 @@ | ||
package org.folio.search.service.setter.bibframe.authority; | ||
|
||
import org.folio.search.domain.dto.BibframeAuthority; | ||
import org.folio.search.service.setter.FieldProcessor; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class BibframeAuthorityTypeProcessor implements FieldProcessor<BibframeAuthority, String> { | ||
|
||
@Override | ||
public String getFieldValue(BibframeAuthority bibframe) { | ||
var type = bibframe.getType(); | ||
if (type == null) { | ||
return null; | ||
} | ||
return type.toString(); | ||
} | ||
} |
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
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,45 @@ | ||
{ | ||
"name": "bibframe-authority", | ||
"eventBodyJavaClass": "org.folio.search.domain.dto.BibframeAuthority", | ||
"languageSourcePaths": ["$.languages"], | ||
"fields": { | ||
"id": { | ||
"index": "keyword" | ||
}, | ||
"label": { | ||
"index": "whitespace" | ||
}, | ||
"type": { | ||
"index": "keyword" | ||
}, | ||
"identifiers": { | ||
"type": "object", | ||
"properties": { | ||
"value": { | ||
"index": "whitespace" | ||
}, | ||
"type": { | ||
"index": "whitespace" | ||
} | ||
} | ||
} | ||
}, | ||
"searchFields": { | ||
"label": { | ||
"type": "search", | ||
"index": "multilang", | ||
"processor": "bibframeAuthorityLabelProcessor" | ||
}, | ||
"type": { | ||
"type": "search", | ||
"index": "keyword", | ||
"processor": "bibframeAuthorityTypeProcessor" | ||
}, | ||
"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' |
Oops, something went wrong.