Skip to content

Commit

Permalink
update bug
Browse files Browse the repository at this point in the history
  • Loading branch information
vietnguyengit committed Oct 22, 2024
1 parent a1a67d0 commit 420423b
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,11 @@ public void createIndexFromMappingJSONFile(String indexMappingFile, String index
log.info("Reading index schema definition from JSON file: {}", indexMappingFile);

// https://www.baeldung.com/java-classpath-resource-cannot-be-opened#resources
try (InputStream inputStream = getClass().getResourceAsStream("config_files/" + indexMappingFile);
BufferedReader reader = new BufferedReader(new InputStreamReader(Objects.requireNonNull(inputStream)))) {
try (InputStream inputStream = getClass().getResourceAsStream("/config_files/" + indexMappingFile);) {
log.info("Creating index: {}", indexName);
CreateIndexRequest req = CreateIndexRequest.of(b -> b
.index(indexName)
.withJson(reader)
.withJson(inputStream)
);
CreateIndexResponse response = portalElasticsearchClient.indices().create(req);
log.info(response.toString());
Expand Down

0 comments on commit 420423b

Please sign in to comment.