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>
|
<properties>
|
||||||
<persistence-service.version>2.93.0</persistence-service.version>
|
<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>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.knecon.fforesight</groupId>
|
<groupId>com.knecon.fforesight</groupId>
|
||||||
<artifactId>tenant-commons</artifactId>
|
<artifactId>tenant-commons</artifactId>
|
||||||
<version>${tennat-commons.version}</version>
|
<version>${tenant-commons.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.guava</groupId>
|
<groupId>com.google.guava</groupId>
|
||||||
|
|||||||
@ -26,7 +26,7 @@ public class DocumentDeleteServiceImpl implements DocumentDeleteService {
|
|||||||
|
|
||||||
public void deleteDocument(String fileId) {
|
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 {
|
try {
|
||||||
clientCache.getClient().delete(request);
|
clientCache.getClient().delete(request);
|
||||||
|
|||||||
@ -32,7 +32,7 @@ public class DocumentIndexServiceImpl implements DocumentIndexService {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
clientCache.getClient()
|
clientCache.getClient()
|
||||||
.index(i -> i.index(TenantContext.getTenantId())
|
.index(i -> i.index(clientCache.getClient().getSearchConnection().getIndexName())
|
||||||
.id(indexDocument.getFileId())
|
.id(indexDocument.getFileId())
|
||||||
.refresh(Refresh._DESERIALIZER.parse(settings.getRefreshPolicy()))
|
.refresh(Refresh._DESERIALIZER.parse(settings.getRefreshPolicy()))
|
||||||
.document(indexDocument));
|
.document(indexDocument));
|
||||||
|
|||||||
@ -32,7 +32,7 @@ public class DocumentUpdateServiceImpl implements DocumentUpdateService {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
clientCache.getClient()
|
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);
|
IndexDocumentUpdate.class);
|
||||||
} catch (IOException | ElasticsearchException e) {
|
} catch (IOException | ElasticsearchException e) {
|
||||||
throw IndexException.documentUpdateError(fileId, e);
|
throw IndexException.documentUpdateError(fileId, e);
|
||||||
|
|||||||
@ -32,7 +32,7 @@ public class IndexCreatorServiceImpl {
|
|||||||
|
|
||||||
if (!indexExists(esClient)) {
|
if (!indexExists(esClient)) {
|
||||||
try {
|
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());
|
log.info("Successfully created index: {}", response.index());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error("Failed to create index.", e);
|
log.error("Failed to create index.", e);
|
||||||
@ -44,7 +44,7 @@ public class IndexCreatorServiceImpl {
|
|||||||
private boolean indexExists(EsClient esClient) {
|
private boolean indexExists(EsClient esClient) {
|
||||||
|
|
||||||
try {
|
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();
|
return response.value();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw IndexException.indexExists(e);
|
throw IndexException.indexExists(e);
|
||||||
|
|||||||
@ -32,7 +32,7 @@ public class IndexDeleteServiceImpl implements IndexDeleteService {
|
|||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public void closeIndex() {
|
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()) {
|
if (closeIndexResponse.acknowledged()) {
|
||||||
log.info("Index is closed");
|
log.info("Index is closed");
|
||||||
} else {
|
} else {
|
||||||
@ -45,7 +45,7 @@ public class IndexDeleteServiceImpl implements IndexDeleteService {
|
|||||||
public void dropIndex() {
|
public void dropIndex() {
|
||||||
|
|
||||||
log.info("Will drop index");
|
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()) {
|
if (deleteIndexResponse.acknowledged()) {
|
||||||
log.info("Index is dropped");
|
log.info("Index is dropped");
|
||||||
|
|||||||
@ -71,7 +71,7 @@ public class SearchServiceImpl implements SearchService {
|
|||||||
highlightFieldMap.put("filename", new HighlightField.Builder().build());
|
highlightFieldMap.put("filename", new HighlightField.Builder().build());
|
||||||
highlightFieldMap.put("fileAttributes.value", 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,
|
.query(convertQuery(query,
|
||||||
dossierTemplateIds,
|
dossierTemplateIds,
|
||||||
dossierIds,
|
dossierIds,
|
||||||
|
|||||||
@ -26,7 +26,7 @@ public class DocumentDeleteServiceImpl implements DocumentDeleteService {
|
|||||||
|
|
||||||
public void deleteDocument(String fileId) {
|
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 {
|
try {
|
||||||
clientCache.getClient().delete(request);
|
clientCache.getClient().delete(request);
|
||||||
|
|||||||
@ -31,7 +31,7 @@ public class DocumentIndexServiceImpl implements DocumentIndexService {
|
|||||||
public void indexDocument(IndexDocument indexDocument) {
|
public void indexDocument(IndexDocument indexDocument) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
clientCache.getClient().index(i -> i.index(TenantContext.getTenantId())
|
clientCache.getClient().index(i -> i.index(clientCache.getClient().getSearchConnection().getIndexName())
|
||||||
.id(indexDocument.getFileId())
|
.id(indexDocument.getFileId())
|
||||||
.refresh(Refresh._DESERIALIZER.parse(settings.getRefreshPolicy()))
|
.refresh(Refresh._DESERIALIZER.parse(settings.getRefreshPolicy()))
|
||||||
.document(indexDocument));
|
.document(indexDocument));
|
||||||
|
|||||||
@ -32,7 +32,7 @@ public class DocumentUpdateServiceImpl implements DocumentUpdateService {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
clientCache.getClient()
|
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);
|
IndexDocumentUpdate.class);
|
||||||
} catch (IOException | OpenSearchException e) {
|
} catch (IOException | OpenSearchException e) {
|
||||||
throw IndexException.documentUpdateError(fileId, e);
|
throw IndexException.documentUpdateError(fileId, e);
|
||||||
|
|||||||
@ -34,7 +34,7 @@ public class IndexCreatorServiceImpl {
|
|||||||
if (!indexExists(client)) {
|
if (!indexExists(client)) {
|
||||||
|
|
||||||
try {
|
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());
|
log.info("Successfully created index: {}", response.index());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error("Failed to create index.", e);
|
log.error("Failed to create index.", e);
|
||||||
@ -46,7 +46,7 @@ public class IndexCreatorServiceImpl {
|
|||||||
private boolean indexExists(OpensearchClient client) {
|
private boolean indexExists(OpensearchClient client) {
|
||||||
|
|
||||||
try {
|
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();
|
return response.value();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw IndexException.indexExists(e);
|
throw IndexException.indexExists(e);
|
||||||
|
|||||||
@ -32,7 +32,7 @@ public class IndexDeleteServiceImpl implements IndexDeleteService {
|
|||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public void closeIndex() {
|
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()) {
|
if (closeIndexResponse.acknowledged()) {
|
||||||
log.info("Index is closed");
|
log.info("Index is closed");
|
||||||
} else {
|
} else {
|
||||||
@ -45,7 +45,7 @@ public class IndexDeleteServiceImpl implements IndexDeleteService {
|
|||||||
public void dropIndex() {
|
public void dropIndex() {
|
||||||
|
|
||||||
log.info("Will drop index");
|
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()) {
|
if (deleteIndexResponse.acknowledged()) {
|
||||||
log.info("Index is dropped");
|
log.info("Index is dropped");
|
||||||
|
|||||||
@ -72,7 +72,7 @@ public class SearchServiceImpl implements SearchService {
|
|||||||
highlightFieldMap.put("filename", new HighlightField.Builder().build());
|
highlightFieldMap.put("filename", new HighlightField.Builder().build());
|
||||||
highlightFieldMap.put("fileAttributes.value", 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,
|
.query(convertQuery(query,
|
||||||
dossierTemplateIds,
|
dossierTemplateIds,
|
||||||
dossierIds,
|
dossierIds,
|
||||||
|
|||||||
@ -57,7 +57,7 @@ public abstract class AbstractElasticsearchIntegrationTest {
|
|||||||
|
|
||||||
TenantContext.setTenantId("redaction");
|
TenantContext.setTenantId("redaction");
|
||||||
when(tenantsClient.getTenant("redaction")).thenReturn(TenantResponse.builder()
|
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());
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -55,7 +55,7 @@ public abstract class AbstractOpensearchIntegrationTest {
|
|||||||
|
|
||||||
TenantContext.setTenantId("redaction");
|
TenantContext.setTenantId("redaction");
|
||||||
when(tenantsClient.getTenant("redaction")).thenReturn(TenantResponse.builder()
|
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());
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user