RED-7175: adapted index name to corresponding places to make it available for search index
This commit is contained in:
parent
e24dfe7fbe
commit
9ee4c8cd91
@ -13,14 +13,14 @@
|
||||
|
||||
<properties>
|
||||
<persistence-service.version>2.93.0</persistence-service.version>
|
||||
<tennat-commons.version>0.10.0</tennat-commons.version>
|
||||
<tenant-commons.version>0.12.0</tenant-commons.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.knecon.fforesight</groupId>
|
||||
<artifactId>tenant-commons</artifactId>
|
||||
<version>${tennat-commons.version}</version>
|
||||
<version>${tenant-commons.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
|
||||
@ -26,7 +26,7 @@ public class DocumentDeleteServiceImpl implements DocumentDeleteService {
|
||||
|
||||
public void deleteDocument(String fileId) {
|
||||
|
||||
DeleteRequest request = new DeleteRequest.Builder().index(TenantContext.getTenantId()).id(fileId).refresh(Refresh._DESERIALIZER.parse(settings.getRefreshPolicy())).build();
|
||||
DeleteRequest request = new DeleteRequest.Builder().index(clientCache.getClient().getSearchConnection().getIndexName()).id(fileId).refresh(Refresh._DESERIALIZER.parse(settings.getRefreshPolicy())).build();
|
||||
|
||||
try {
|
||||
clientCache.getClient().delete(request);
|
||||
|
||||
@ -32,7 +32,7 @@ public class DocumentIndexServiceImpl implements DocumentIndexService {
|
||||
|
||||
try {
|
||||
clientCache.getClient()
|
||||
.index(i -> i.index(TenantContext.getTenantId())
|
||||
.index(i -> i.index(clientCache.getClient().getSearchConnection().getIndexName())
|
||||
.id(indexDocument.getFileId())
|
||||
.refresh(Refresh._DESERIALIZER.parse(settings.getRefreshPolicy()))
|
||||
.document(indexDocument));
|
||||
|
||||
@ -32,7 +32,7 @@ public class DocumentUpdateServiceImpl implements DocumentUpdateService {
|
||||
|
||||
try {
|
||||
clientCache.getClient()
|
||||
.update(u -> u.index(TenantContext.getTenantId()).id(fileId).doc(indexDocumentUpdate).refresh(Refresh._DESERIALIZER.parse(settings.getRefreshPolicy())),
|
||||
.update(u -> u.index(clientCache.getClient().getSearchConnection().getIndexName()).id(fileId).doc(indexDocumentUpdate).refresh(Refresh._DESERIALIZER.parse(settings.getRefreshPolicy())),
|
||||
IndexDocumentUpdate.class);
|
||||
} catch (IOException | ElasticsearchException e) {
|
||||
throw IndexException.documentUpdateError(fileId, e);
|
||||
|
||||
@ -32,7 +32,7 @@ public class IndexCreatorServiceImpl {
|
||||
|
||||
if (!indexExists(esClient)) {
|
||||
try {
|
||||
var response = esClient.indices().create(i -> i.index(TenantContext.getTenantId()).settings(createIndexSettings(esClient)).mappings(createIndexMapping()));
|
||||
var response = esClient.indices().create(i -> i.index(esClient.getSearchConnection().getIndexName()).settings(createIndexSettings(esClient)).mappings(createIndexMapping()));
|
||||
log.info("Successfully created index: {}", response.index());
|
||||
} catch (IOException e) {
|
||||
log.error("Failed to create index.", e);
|
||||
@ -44,7 +44,7 @@ public class IndexCreatorServiceImpl {
|
||||
private boolean indexExists(EsClient esClient) {
|
||||
|
||||
try {
|
||||
var response = esClient.indices().exists(i -> i.index(TenantContext.getTenantId()));
|
||||
var response = esClient.indices().exists(i -> i.index(esClient.getSearchConnection().getIndexName()));
|
||||
return response.value();
|
||||
} catch (IOException e) {
|
||||
throw IndexException.indexExists(e);
|
||||
|
||||
@ -32,7 +32,7 @@ public class IndexDeleteServiceImpl implements IndexDeleteService {
|
||||
@SneakyThrows
|
||||
public void closeIndex() {
|
||||
|
||||
var closeIndexResponse = clientCache.getClient().indices().close(i -> i.index(TenantContext.getTenantId()).timeout(t -> t.time("2m")));
|
||||
var closeIndexResponse = clientCache.getClient().indices().close(i -> i.index(clientCache.getClient().getSearchConnection().getIndexName()).timeout(t -> t.time("2m")));
|
||||
if (closeIndexResponse.acknowledged()) {
|
||||
log.info("Index is closed");
|
||||
} else {
|
||||
@ -45,7 +45,7 @@ public class IndexDeleteServiceImpl implements IndexDeleteService {
|
||||
public void dropIndex() {
|
||||
|
||||
log.info("Will drop index");
|
||||
var deleteIndexResponse = clientCache.getClient().indices().delete(i -> i.index(TenantContext.getTenantId()).timeout(t -> t.time("2m")));
|
||||
var deleteIndexResponse = clientCache.getClient().indices().delete(i -> i.index(clientCache.getClient().getSearchConnection().getIndexName()).timeout(t -> t.time("2m")));
|
||||
|
||||
if (deleteIndexResponse.acknowledged()) {
|
||||
log.info("Index is dropped");
|
||||
|
||||
@ -71,7 +71,7 @@ public class SearchServiceImpl implements SearchService {
|
||||
highlightFieldMap.put("filename", new HighlightField.Builder().build());
|
||||
highlightFieldMap.put("fileAttributes.value", new HighlightField.Builder().build());
|
||||
|
||||
SearchRequest request = new SearchRequest.Builder().index(TenantContext.getTenantId())
|
||||
SearchRequest request = new SearchRequest.Builder().index(clientCache.getClient().getSearchConnection().getIndexName())
|
||||
.query(convertQuery(query,
|
||||
dossierTemplateIds,
|
||||
dossierIds,
|
||||
|
||||
@ -26,7 +26,7 @@ public class DocumentDeleteServiceImpl implements DocumentDeleteService {
|
||||
|
||||
public void deleteDocument(String fileId) {
|
||||
|
||||
DeleteRequest request = new DeleteRequest.Builder().index(TenantContext.getTenantId()).id(fileId).refresh(Refresh._DESERIALIZER.parse(settings.getRefreshPolicy())).build();
|
||||
DeleteRequest request = new DeleteRequest.Builder().index(clientCache.getClient().getSearchConnection().getIndexName()).id(fileId).refresh(Refresh._DESERIALIZER.parse(settings.getRefreshPolicy())).build();
|
||||
|
||||
try {
|
||||
clientCache.getClient().delete(request);
|
||||
|
||||
@ -31,7 +31,7 @@ public class DocumentIndexServiceImpl implements DocumentIndexService {
|
||||
public void indexDocument(IndexDocument indexDocument) {
|
||||
|
||||
try {
|
||||
clientCache.getClient().index(i -> i.index(TenantContext.getTenantId())
|
||||
clientCache.getClient().index(i -> i.index(clientCache.getClient().getSearchConnection().getIndexName())
|
||||
.id(indexDocument.getFileId())
|
||||
.refresh(Refresh._DESERIALIZER.parse(settings.getRefreshPolicy()))
|
||||
.document(indexDocument));
|
||||
|
||||
@ -32,7 +32,7 @@ public class DocumentUpdateServiceImpl implements DocumentUpdateService {
|
||||
|
||||
try {
|
||||
clientCache.getClient()
|
||||
.update(u -> u.index(TenantContext.getTenantId()).id(fileId).doc(indexDocumentUpdate).refresh(Refresh._DESERIALIZER.parse(settings.getRefreshPolicy())),
|
||||
.update(u -> u.index(clientCache.getClient().getSearchConnection().getIndexName()).id(fileId).doc(indexDocumentUpdate).refresh(Refresh._DESERIALIZER.parse(settings.getRefreshPolicy())),
|
||||
IndexDocumentUpdate.class);
|
||||
} catch (IOException | OpenSearchException e) {
|
||||
throw IndexException.documentUpdateError(fileId, e);
|
||||
|
||||
@ -34,7 +34,7 @@ public class IndexCreatorServiceImpl {
|
||||
if (!indexExists(client)) {
|
||||
|
||||
try {
|
||||
var response = client.indices().create(i -> i.index(TenantContext.getTenantId()).settings(createIndexSettings(client)).mappings(createIndexMapping(client)));
|
||||
var response = client.indices().create(i -> i.index(client.getSearchConnection().getIndexName()).settings(createIndexSettings(client)).mappings(createIndexMapping(client)));
|
||||
log.info("Successfully created index: {}", response.index());
|
||||
} catch (IOException e) {
|
||||
log.error("Failed to create index.", e);
|
||||
@ -46,7 +46,7 @@ public class IndexCreatorServiceImpl {
|
||||
private boolean indexExists(OpensearchClient client) {
|
||||
|
||||
try {
|
||||
var response = client.indices().exists(i -> i.index(TenantContext.getTenantId()));
|
||||
var response = client.indices().exists(i -> i.index(client.getSearchConnection().getIndexName()));
|
||||
return response.value();
|
||||
} catch (IOException e) {
|
||||
throw IndexException.indexExists(e);
|
||||
|
||||
@ -32,7 +32,7 @@ public class IndexDeleteServiceImpl implements IndexDeleteService {
|
||||
@SneakyThrows
|
||||
public void closeIndex() {
|
||||
|
||||
var closeIndexResponse = clientCache.getClient().indices().close(i -> i.index(TenantContext.getTenantId()).timeout(t -> t.time("2m")));
|
||||
var closeIndexResponse = clientCache.getClient().indices().close(i -> i.index(clientCache.getClient().getSearchConnection().getIndexName()).timeout(t -> t.time("2m")));
|
||||
if (closeIndexResponse.acknowledged()) {
|
||||
log.info("Index is closed");
|
||||
} else {
|
||||
@ -45,7 +45,7 @@ public class IndexDeleteServiceImpl implements IndexDeleteService {
|
||||
public void dropIndex() {
|
||||
|
||||
log.info("Will drop index");
|
||||
var deleteIndexResponse = clientCache.getClient().indices().delete(i -> i.index(TenantContext.getTenantId()).timeout(t -> t.time("2m")));
|
||||
var deleteIndexResponse = clientCache.getClient().indices().delete(i -> i.index(clientCache.getClient().getSearchConnection().getIndexName()).timeout(t -> t.time("2m")));
|
||||
|
||||
if (deleteIndexResponse.acknowledged()) {
|
||||
log.info("Index is dropped");
|
||||
|
||||
@ -72,7 +72,7 @@ public class SearchServiceImpl implements SearchService {
|
||||
highlightFieldMap.put("filename", new HighlightField.Builder().build());
|
||||
highlightFieldMap.put("fileAttributes.value", new HighlightField.Builder().build());
|
||||
|
||||
SearchRequest request = new SearchRequest.Builder().index(TenantContext.getTenantId())
|
||||
SearchRequest request = new SearchRequest.Builder().index(clientCache.getClient().getSearchConnection().getIndexName())
|
||||
.query(convertQuery(query,
|
||||
dossierTemplateIds,
|
||||
dossierIds,
|
||||
|
||||
@ -57,7 +57,7 @@ public abstract class AbstractElasticsearchIntegrationTest {
|
||||
|
||||
TenantContext.setTenantId("redaction");
|
||||
when(tenantsClient.getTenant("redaction")).thenReturn(TenantResponse.builder()
|
||||
.searchConnection(SearchConnection.builder().hosts(Set.of("localhost")).port(port).scheme("http").numberOfShards("1").numberOfReplicas("5").build())
|
||||
.searchConnection(SearchConnection.builder().hosts(Set.of("localhost")).port(port).scheme("http").numberOfShards("1").numberOfReplicas("5").indexName("indexname").build())
|
||||
.build());
|
||||
}
|
||||
|
||||
|
||||
@ -55,7 +55,7 @@ public abstract class AbstractOpensearchIntegrationTest {
|
||||
|
||||
TenantContext.setTenantId("redaction");
|
||||
when(tenantsClient.getTenant("redaction")).thenReturn(TenantResponse.builder()
|
||||
.searchConnection(SearchConnection.builder().hosts(Set.of("localhost")).port(port).scheme("http").numberOfShards("1").numberOfReplicas("5").build())
|
||||
.searchConnection(SearchConnection.builder().hosts(Set.of("localhost")).port(port).scheme("http").numberOfShards("1").numberOfReplicas("5").indexName("indexname").build())
|
||||
.build());
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user