Minor: Ensure correct index mapping in Elasticsearch for clusterAlias (#16598)

This commit is contained in:
sonika-shah 2024-06-11 10:06:44 +05:30 committed by GitHub
parent 8723b8c36a
commit 04543722a6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 17 additions and 6 deletions

View File

@ -27,6 +27,7 @@ import static org.openmetadata.service.exception.CatalogExceptionMessage.notRevi
import static org.openmetadata.service.resources.tags.TagLabelUtil.checkMutuallyExclusive;
import static org.openmetadata.service.resources.tags.TagLabelUtil.checkMutuallyExclusiveForParentAndSubField;
import static org.openmetadata.service.resources.tags.TagLabelUtil.getUniqueTags;
import static org.openmetadata.service.search.SearchClient.GLOBAL_SEARCH_ALIAS;
import static org.openmetadata.service.util.EntityUtil.compareEntityReferenceById;
import static org.openmetadata.service.util.EntityUtil.compareTagLabel;
import static org.openmetadata.service.util.EntityUtil.entityReferenceMatch;
@ -425,7 +426,9 @@ public class GlossaryTermRepository extends EntityRepository<GlossaryTerm> {
String key = "_source";
SearchRequest searchRequest =
new SearchRequest.ElasticSearchRequestBuilder(
String.format("** AND (tags.tagFQN:\"%s\")", glossaryFqn), size, "all")
String.format("** AND (tags.tagFQN:\"%s\")", glossaryFqn),
size,
Entity.getSearchRepository().getIndexOrAliasName(GLOBAL_SEARCH_ALIAS))
.from(0)
.fetchSource(true)
.trackTotalHits(false)
@ -474,7 +477,8 @@ public class GlossaryTermRepository extends EntityRepository<GlossaryTerm> {
termFQN);
SearchRequest searchRequest =
new SearchRequest.ElasticSearchRequestBuilder("*", size, "all")
new SearchRequest.ElasticSearchRequestBuilder(
"*", size, Entity.getSearchRepository().getIndexOrAliasName(GLOBAL_SEARCH_ALIAS))
.from(0)
.queryFilter(queryFilter)
.fetchSource(true)

View File

@ -279,7 +279,9 @@ public class SystemRepository {
private StepValidation getSearchValidation(OpenMetadataApplicationConfig applicationConfig) {
SearchRepository searchRepository = Entity.getSearchRepository();
if (Boolean.TRUE.equals(searchRepository.getSearchClient().isClientAvailable())
&& searchRepository.getSearchClient().indexExists(INDEX_NAME)) {
&& searchRepository
.getSearchClient()
.indexExists(Entity.getSearchRepository().getIndexOrAliasName(INDEX_NAME))) {
return new StepValidation()
.withDescription(ValidationStepDescription.SEARCH.key)
.withPassed(Boolean.TRUE)

View File

@ -514,7 +514,8 @@ public class ElasticSearchClient implements SearchClient {
@Override
public Response getDocByID(String indexName, String entityId) throws IOException {
try {
GetRequest request = new GetRequest(indexName, entityId);
GetRequest request =
new GetRequest(Entity.getSearchRepository().getIndexOrAliasName(indexName), entityId);
GetResponse response = client.get(request, RequestOptions.DEFAULT);
if (response.isExists()) {

View File

@ -505,7 +505,8 @@ public class OpenSearchClient implements SearchClient {
@Override
public Response getDocByID(String indexName, String entityId) throws IOException {
try {
GetRequest request = new GetRequest(indexName, entityId);
GetRequest request =
new GetRequest(Entity.getSearchRepository().getIndexOrAliasName(indexName), entityId);
GetResponse response = client.get(request, RequestOptions.DEFAULT);
if (response.isExists()) {

View File

@ -14,6 +14,7 @@
package org.openmetadata.service.workflows.searchIndex;
import static org.openmetadata.service.apps.bundles.searchIndex.SearchIndexApp.TIME_SERIES_ENTITIES;
import static org.openmetadata.service.search.SearchClient.GLOBAL_SEARCH_ALIAS;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
@ -130,7 +131,9 @@ public class ReindexingUtil {
String key = "_source";
SearchRequest searchRequest =
new SearchRequest.ElasticSearchRequestBuilder(
String.format("(%s:\"%s\")", matchingKey, sourceFqn), 100, "all")
String.format("(%s:\"%s\")", matchingKey, sourceFqn),
100,
Entity.getSearchRepository().getIndexOrAliasName(GLOBAL_SEARCH_ALIAS))
.from(from)
.fetchSource(true)
.trackTotalHits(false)