diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/search/SearchResource.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/search/SearchResource.java index bee12b59222..bc73e33c1c9 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/search/SearchResource.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/search/SearchResource.java @@ -114,10 +114,9 @@ public class SearchResource { @QueryParam("index") String index, @Parameter(description = "Filter documents by deleted param. By default deleted is false") - @DefaultValue("false") @QueryParam("deleted") @Deprecated(forRemoval = true) - boolean deleted, + Boolean deleted, @Parameter(description = "From field to paginate the results, defaults to 0") @DefaultValue("0") @QueryParam("from") diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/search/SearchSourceBuilderFactory.java b/openmetadata-service/src/main/java/org/openmetadata/service/search/SearchSourceBuilderFactory.java index 99707ad6c76..18c5f611e41 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/search/SearchSourceBuilderFactory.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/search/SearchSourceBuilderFactory.java @@ -42,6 +42,25 @@ public interface SearchSourceBuilderFactory { "[+\\-~\\^]" // Special operators ); + Set FUZZY_FIELDS = + Set.of( + "name", + "displayName", + "fullyQualifiedName", + "columnNamesFuzzy", + "fieldNamesFuzzy", + "response_field_namesFuzzy", + "request_field_namesFuzzy", + "classification.name", + "classification.displayName", + "glossary.name", + "glossary.displayName"); + + // Keyword fields added to fuzzy because Lucene needs keyword fields for wildcard/prefix queries + // in query_string + Set FUZZY_AND_NON_FUZZY_FIELDS = + Set.of("name.keyword", "displayName.keyword", "fullyQualifiedName.keyword"); + /** * Get the appropriate search source builder based on the index name. * @@ -236,18 +255,16 @@ public interface SearchSourceBuilderFactory { } default boolean isFuzzyField(String key) { - return Set.of( - "name", - "displayName", - "fullyQualifiedName", - "columnNamesFuzzy", - "fieldNamesFuzzy", - "response_field_namesFuzzy", - "request_field_namesFuzzy", - "classification.name", - "classification.displayName", - "glossary.name", - "glossary.displayName") - .contains(key); + if (FUZZY_AND_NON_FUZZY_FIELDS.contains(key)) { + return true; + } + return FUZZY_FIELDS.contains(key); + } + + default boolean isNonFuzzyField(String key) { + if (FUZZY_AND_NON_FUZZY_FIELDS.contains(key)) { + return true; + } + return !FUZZY_FIELDS.contains(key); } } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/search/elasticsearch/ElasticSearchClient.java b/openmetadata-service/src/main/java/org/openmetadata/service/search/elasticsearch/ElasticSearchClient.java index 4a1904a810f..4e5a81a0fc8 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/search/elasticsearch/ElasticSearchClient.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/search/elasticsearch/ElasticSearchClient.java @@ -3,12 +3,8 @@ package org.openmetadata.service.search.elasticsearch; import static javax.ws.rs.core.Response.Status.NOT_FOUND; import static javax.ws.rs.core.Response.Status.OK; import static org.openmetadata.common.utils.CommonUtil.nullOrEmpty; -import static org.openmetadata.service.Entity.AGGREGATED_COST_ANALYSIS_REPORT_DATA; -import static org.openmetadata.service.Entity.DATA_PRODUCT; import static org.openmetadata.service.Entity.DOMAIN; import static org.openmetadata.service.Entity.GLOSSARY_TERM; -import static org.openmetadata.service.Entity.QUERY; -import static org.openmetadata.service.Entity.RAW_COST_ANALYSIS_REPORT_DATA; import static org.openmetadata.service.Entity.TABLE; import static org.openmetadata.service.events.scheduled.ServicesStatusJobHandler.HEALTHY_STATUS; import static org.openmetadata.service.events.scheduled.ServicesStatusJobHandler.UNHEALTHY_STATUS; @@ -365,6 +361,7 @@ public class ElasticSearchClient implements SearchClient { public Response doSearch( SearchRequest request, SubjectContext subjectContext, SearchSettings searchSettings) throws IOException { + String indexName = Entity.getSearchRepository().getIndexNameWithoutAlias(request.getIndex()); ElasticSearchSourceBuilderFactory searchBuilderFactory = new ElasticSearchSourceBuilderFactory(searchSettings); SearchSourceBuilder searchSourceBuilder = @@ -396,60 +393,26 @@ public class ElasticSearchClient implements SearchClient { } /* For backward-compatibility we continue supporting the deleted argument, this should be removed in future versions */ - if (request - .getIndex() - .equalsIgnoreCase(Entity.getSearchRepository().getIndexOrAliasName(GLOBAL_SEARCH_ALIAS)) - || request - .getIndex() - .equalsIgnoreCase(Entity.getSearchRepository().getIndexOrAliasName("dataAsset"))) { - es.org.elasticsearch.index.query.BoolQueryBuilder boolQueryBuilder = - QueryBuilders.boolQuery(); - boolQueryBuilder.should( - QueryBuilders.boolQuery() - .must(searchSourceBuilder.query()) - .must(QueryBuilders.existsQuery("deleted")) - .must(QueryBuilders.termQuery("deleted", request.getDeleted()))); - boolQueryBuilder.should( - QueryBuilders.boolQuery() - .must(searchSourceBuilder.query()) - .mustNot(QueryBuilders.existsQuery("deleted"))); - searchSourceBuilder.query(boolQueryBuilder); - } else if (request - .getIndex() - .equalsIgnoreCase( - Entity.getSearchRepository().getIndexMapping(DOMAIN).getIndexName(clusterAlias)) - || request - .getIndex() - .equalsIgnoreCase( - Entity.getSearchRepository() - .getIndexMapping(DATA_PRODUCT) - .getIndexName(clusterAlias)) - || request - .getIndex() - .equalsIgnoreCase( - Entity.getSearchRepository().getIndexMapping(QUERY).getIndexName(clusterAlias)) - || request - .getIndex() - .equalsIgnoreCase( - Entity.getSearchRepository().getIndexOrAliasName("knowledge_page_search_index")) - || request - .getIndex() - .equalsIgnoreCase( - Entity.getSearchRepository() - .getIndexMapping(RAW_COST_ANALYSIS_REPORT_DATA) - .getIndexName(clusterAlias)) - || request - .getIndex() - .equalsIgnoreCase( - Entity.getSearchRepository() - .getIndexMapping(AGGREGATED_COST_ANALYSIS_REPORT_DATA) - .getIndexName(clusterAlias))) { - searchSourceBuilder.query(QueryBuilders.boolQuery().must(searchSourceBuilder.query())); - } else { - searchSourceBuilder.query( - QueryBuilders.boolQuery() - .must(searchSourceBuilder.query()) - .must(QueryBuilders.termQuery("deleted", request.getDeleted()))); + if (!nullOrEmpty(request.getDeleted())) { + if (indexName.equals(GLOBAL_SEARCH_ALIAS) || indexName.equals(DATA_ASSET_SEARCH_ALIAS)) { + BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery(); + + boolQueryBuilder.should( + QueryBuilders.boolQuery() + .must(searchSourceBuilder.query()) + .must(QueryBuilders.existsQuery("deleted")) + .must(QueryBuilders.termQuery("deleted", request.getDeleted()))); + boolQueryBuilder.should( + QueryBuilders.boolQuery() + .must(searchSourceBuilder.query()) + .mustNot(QueryBuilders.existsQuery("deleted"))); + searchSourceBuilder.query(boolQueryBuilder); + } else { + searchSourceBuilder.query( + QueryBuilders.boolQuery() + .must(searchSourceBuilder.query()) + .must(QueryBuilders.termQuery("deleted", request.getDeleted()))); + } } if (!nullOrEmpty(request.getSortFieldParam()) && !request.getIsHierarchy()) { diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/search/elasticsearch/ElasticSearchSourceBuilderFactory.java b/openmetadata-service/src/main/java/org/openmetadata/service/search/elasticsearch/ElasticSearchSourceBuilderFactory.java index dc868599627..b10c99689ad 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/search/elasticsearch/ElasticSearchSourceBuilderFactory.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/search/elasticsearch/ElasticSearchSourceBuilderFactory.java @@ -55,7 +55,7 @@ public class ElasticSearchSourceBuilderFactory Map nonFuzzyFields = fields.entrySet().stream() - .filter(entry -> !isFuzzyField(entry.getKey())) + .filter(entry -> isNonFuzzyField(entry.getKey())) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); QueryStringQueryBuilder fuzzyQueryBuilder = @@ -174,7 +174,7 @@ public class ElasticSearchSourceBuilderFactory .collect(Collectors.toMap(FieldBoost::getField, fb -> fb.getBoost().floatValue())); nonFuzzyFields = assetConfig.getSearchFields().stream() - .filter(fieldBoost -> !isFuzzyField(fieldBoost.getField())) + .filter(fieldBoost -> isNonFuzzyField(fieldBoost.getField())) .collect(Collectors.toMap(FieldBoost::getField, fb -> fb.getBoost().floatValue())); } else { Map defaultFields = SearchIndex.getDefaultFields(); @@ -184,7 +184,7 @@ public class ElasticSearchSourceBuilderFactory .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); nonFuzzyFields = defaultFields.entrySet().stream() - .filter(entry -> !isFuzzyField(entry.getKey())) + .filter(entry -> isNonFuzzyField(entry.getKey())) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/search/indexes/SearchIndex.java b/openmetadata-service/src/main/java/org/openmetadata/service/search/indexes/SearchIndex.java index 29bc86a1d90..2c18565ac0d 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/search/indexes/SearchIndex.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/search/indexes/SearchIndex.java @@ -13,6 +13,7 @@ import static org.openmetadata.service.search.EntityBuilderConstant.FIELD_DISPLA import static org.openmetadata.service.search.EntityBuilderConstant.FIELD_NAME_NGRAM; import static org.openmetadata.service.search.EntityBuilderConstant.FULLY_QUALIFIED_NAME; import static org.openmetadata.service.search.EntityBuilderConstant.FULLY_QUALIFIED_NAME_PARTS; +import static org.openmetadata.service.search.EntityBuilderConstant.NAME_KEYWORD; import static org.openmetadata.service.util.FullyQualifiedName.getParentFQN; import java.util.ArrayList; @@ -373,6 +374,7 @@ public interface SearchIndex { static Map getDefaultFields() { Map fields = new HashMap<>(); + fields.put(NAME_KEYWORD, 10.0f); fields.put(DISPLAY_NAME_KEYWORD, 10.0f); fields.put(FIELD_NAME, 10.0f); fields.put(FIELD_NAME_NGRAM, 1.0f); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/search/opensearch/OpenSearchClient.java b/openmetadata-service/src/main/java/org/openmetadata/service/search/opensearch/OpenSearchClient.java index 4427e6b1ff8..81f015ac880 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/search/opensearch/OpenSearchClient.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/search/opensearch/OpenSearchClient.java @@ -3,14 +3,10 @@ package org.openmetadata.service.search.opensearch; import static javax.ws.rs.core.Response.Status.NOT_FOUND; import static javax.ws.rs.core.Response.Status.OK; import static org.openmetadata.common.utils.CommonUtil.nullOrEmpty; -import static org.openmetadata.service.Entity.AGGREGATED_COST_ANALYSIS_REPORT_DATA; -import static org.openmetadata.service.Entity.DATA_PRODUCT; import static org.openmetadata.service.Entity.DOMAIN; import static org.openmetadata.service.Entity.FIELD_DESCRIPTION; import static org.openmetadata.service.Entity.FIELD_DISPLAY_NAME; import static org.openmetadata.service.Entity.GLOSSARY_TERM; -import static org.openmetadata.service.Entity.QUERY; -import static org.openmetadata.service.Entity.RAW_COST_ANALYSIS_REPORT_DATA; import static org.openmetadata.service.Entity.TABLE; import static org.openmetadata.service.events.scheduled.ServicesStatusJobHandler.HEALTHY_STATUS; import static org.openmetadata.service.events.scheduled.ServicesStatusJobHandler.UNHEALTHY_STATUS; @@ -383,6 +379,7 @@ public class OpenSearchClient implements SearchClient { public Response doSearch( SearchRequest request, SubjectContext subjectContext, SearchSettings searchSettings) throws IOException { + String indexName = Entity.getSearchRepository().getIndexNameWithoutAlias(request.getIndex()); OpenSearchSourceBuilderFactory searchBuilderFactory = new OpenSearchSourceBuilderFactory(searchSettings); SearchSourceBuilder searchSourceBuilder = @@ -415,59 +412,26 @@ public class OpenSearchClient implements SearchClient { } /* For backward-compatibility we continue supporting the deleted argument, this should be removed in future versions */ - if (request - .getIndex() - .equalsIgnoreCase(Entity.getSearchRepository().getIndexOrAliasName(GLOBAL_SEARCH_ALIAS)) - || request - .getIndex() - .equalsIgnoreCase(Entity.getSearchRepository().getIndexOrAliasName("dataAsset"))) { - BoolQueryBuilder deletedOptions = - QueryBuilders.boolQuery() - .should( - QueryBuilders.boolQuery() - .must(QueryBuilders.existsQuery("deleted")) - .must(QueryBuilders.termQuery("deleted", request.getDeleted()))) - .should(QueryBuilders.boolQuery().mustNot(QueryBuilders.existsQuery("deleted"))); - BoolQueryBuilder combined = - QueryBuilders.boolQuery().must(searchSourceBuilder.query()).filter(deletedOptions); + if (!nullOrEmpty(request.getDeleted())) { + if (indexName.equals(GLOBAL_SEARCH_ALIAS) || indexName.equals(DATA_ASSET_SEARCH_ALIAS)) { + BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery(); - searchSourceBuilder.query(combined); - } else if (request - .getIndex() - .equalsIgnoreCase( - Entity.getSearchRepository().getIndexMapping(DOMAIN).getIndexName(clusterAlias)) - || request - .getIndex() - .equalsIgnoreCase( - Entity.getSearchRepository() - .getIndexMapping(DATA_PRODUCT) - .getIndexName(clusterAlias)) - || request - .getIndex() - .equalsIgnoreCase( - Entity.getSearchRepository().getIndexMapping(QUERY).getIndexName(clusterAlias)) - || request - .getIndex() - .equalsIgnoreCase( - Entity.getSearchRepository().getIndexOrAliasName("knowledge_page_search_index")) - || request - .getIndex() - .equalsIgnoreCase( - Entity.getSearchRepository() - .getIndexMapping(RAW_COST_ANALYSIS_REPORT_DATA) - .getIndexName(clusterAlias)) - || request - .getIndex() - .equalsIgnoreCase( - Entity.getSearchRepository() - .getIndexMapping(AGGREGATED_COST_ANALYSIS_REPORT_DATA) - .getIndexName(clusterAlias))) { - searchSourceBuilder.query(QueryBuilders.boolQuery().must(searchSourceBuilder.query())); - } else { - searchSourceBuilder.query( - QueryBuilders.boolQuery() - .must(searchSourceBuilder.query()) - .must(QueryBuilders.termQuery("deleted", request.getDeleted()))); + boolQueryBuilder.should( + QueryBuilders.boolQuery() + .must(searchSourceBuilder.query()) + .must(QueryBuilders.existsQuery("deleted")) + .must(QueryBuilders.termQuery("deleted", request.getDeleted()))); + boolQueryBuilder.should( + QueryBuilders.boolQuery() + .must(searchSourceBuilder.query()) + .mustNot(QueryBuilders.existsQuery("deleted"))); + searchSourceBuilder.query(boolQueryBuilder); + } else { + searchSourceBuilder.query( + QueryBuilders.boolQuery() + .must(searchSourceBuilder.query()) + .must(QueryBuilders.termQuery("deleted", request.getDeleted()))); + } } if (!nullOrEmpty(request.getSortFieldParam()) diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/search/opensearch/OpenSearchSourceBuilderFactory.java b/openmetadata-service/src/main/java/org/openmetadata/service/search/opensearch/OpenSearchSourceBuilderFactory.java index d4881007eb3..259121b2269 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/search/opensearch/OpenSearchSourceBuilderFactory.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/search/opensearch/OpenSearchSourceBuilderFactory.java @@ -54,7 +54,7 @@ public class OpenSearchSourceBuilderFactory Map nonFuzzyFields = fields.entrySet().stream() - .filter(entry -> !isFuzzyField(entry.getKey())) + .filter(entry -> isNonFuzzyField(entry.getKey())) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); QueryStringQueryBuilder fuzzyQueryBuilder = @@ -173,7 +173,7 @@ public class OpenSearchSourceBuilderFactory .collect(Collectors.toMap(FieldBoost::getField, fb -> fb.getBoost().floatValue())); nonFuzzyFields = assetConfig.getSearchFields().stream() - .filter(fieldBoost -> !isFuzzyField(fieldBoost.getField())) + .filter(fieldBoost -> isNonFuzzyField(fieldBoost.getField())) .collect(Collectors.toMap(FieldBoost::getField, fb -> fb.getBoost().floatValue())); } else { Map defaultFields = SearchIndex.getDefaultFields(); @@ -183,7 +183,7 @@ public class OpenSearchSourceBuilderFactory .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); nonFuzzyFields = defaultFields.entrySet().stream() - .filter(entry -> !isFuzzyField(entry.getKey())) + .filter(entry -> isNonFuzzyField(entry.getKey())) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); } diff --git a/openmetadata-spec/src/main/resources/json/schema/search/searchRequest.json b/openmetadata-spec/src/main/resources/json/schema/search/searchRequest.json index 2159fffe6c1..32e6628616d 100644 --- a/openmetadata-spec/src/main/resources/json/schema/search/searchRequest.json +++ b/openmetadata-spec/src/main/resources/json/schema/search/searchRequest.json @@ -57,7 +57,8 @@ "deleted": { "description": "Filter documents by deleted param.", "type": "boolean", - "default": false + "default": null, + "existingJavaType": "java.lang.Boolean" }, "sortFieldParam": { "description": "Sort the search results by field, available fields to sort weekly_stats daily_stats, monthly_stats, last_updated_timestamp.", diff --git a/openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/QueryEntity.spec.ts b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/QueryEntity.spec.ts index b35180a99e1..cca60513840 100644 --- a/openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/QueryEntity.spec.ts +++ b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/QueryEntity.spec.ts @@ -66,7 +66,7 @@ test('Query Entity', async ({ page }) => { ); await page.click(`[data-testid="table_queries"]`); const tableResponse = page.waitForResponse( - '/api/v1/search/query?q=**&from=0&size=*&index=table_search_index' + '/api/v1/search/query?q=**&from=0&size=*&index=table_search_index*' ); await queryResponse; await page.click(`[data-testid="add-query-btn"]`); @@ -177,7 +177,7 @@ test('Query Entity', async ({ page }) => { await page.keyboard.type(`${queryData.queryUsedIn.table1}`); await page.click('[data-testid="edit-query-used-in"]'); const tableSearchResponse = page.waitForResponse( - '/api/v1/search/query?q=*&index=table_search_index' + '/api/v1/search/query?q=*&index=table_search_index*' ); await page.keyboard.type(queryData.queryUsedIn.table2); await tableSearchResponse; diff --git a/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/ServiceListing.spec.ts b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/ServiceListing.spec.ts index 656282b7e70..1820c52e020 100644 --- a/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/ServiceListing.spec.ts +++ b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/ServiceListing.spec.ts @@ -43,7 +43,7 @@ test.describe('Service Listing', () => { await page.getByTestId('filter-icon').click(); const searchBigQueryResponse = page.waitForResponse( - `/api/v1/search/query?q=**%20AND%20(serviceType:BigQuery)&from=0&size=15&index=database_service_search_index` + `/api/v1/search/query?q=**%20AND%20(serviceType:BigQuery)&from=0&size=15&index=database_service_search_index*` ); await page.getByLabel('Big Query').check(); await searchBigQueryResponse; @@ -53,7 +53,7 @@ test.describe('Service Listing', () => { await page.getByTestId('filter-icon').click(); const searchResponse = page.waitForResponse( - `/api/v1/search/query?q=**%20AND%20(serviceType:BigQuery%20OR%20serviceType:Mysql)&from=0&size=15&index=database_service_search_index` + `/api/v1/search/query?q=**%20AND%20(serviceType:BigQuery%20OR%20serviceType:Mysql)&from=0&size=15&index=database_service_search_index*` ); await page.getByLabel('Mysql').check(); diff --git a/openmetadata-ui/src/main/resources/ui/playwright/utils/alert.ts b/openmetadata-ui/src/main/resources/ui/playwright/utils/alert.ts index f7246ee038b..2551ded698e 100644 --- a/openmetadata-ui/src/main/resources/ui/playwright/utils/alert.ts +++ b/openmetadata-ui/src/main/resources/ui/playwright/utils/alert.ts @@ -397,7 +397,7 @@ export const addDomainFilter = async ({ // Search and select domain const getSearchResult = page.waitForResponse( - '/api/v1/search/query?q=**index=domain_search_index' + '/api/v1/search/query?q=**index=domain_search_index*' ); await page.fill( '[data-testid="domain-select"] [role="combobox"]', diff --git a/openmetadata-ui/src/main/resources/ui/playwright/utils/domain.ts b/openmetadata-ui/src/main/resources/ui/playwright/utils/domain.ts index 5a11b2a069b..3f5eae2a7fd 100644 --- a/openmetadata-ui/src/main/resources/ui/playwright/utils/domain.ts +++ b/openmetadata-ui/src/main/resources/ui/playwright/utils/domain.ts @@ -136,7 +136,7 @@ export const selectSubDomain = async ( await page.getByTestId('subdomains').getByText('Sub Domains').click(); const res = page.waitForResponse( - '/api/v1/search/query?*&index=data_product_search_index' + '/api/v1/search/query?*&index=data_product_search_index*' ); await page.getByTestId(subDomain.name).click(); await res; @@ -147,7 +147,7 @@ export const selectDataProductFromTab = async ( dataProduct: DataProduct['data'] ) => { const dpRes = page.waitForResponse( - '/api/v1/search/query?*&from=0&size=50&index=data_product_search_index' + '/api/v1/search/query?*&from=0&size=50&index=data_product_search_index*' ); await page .locator('.domain-details-page-tabs') diff --git a/openmetadata-ui/src/main/resources/ui/playwright/utils/glossary.ts b/openmetadata-ui/src/main/resources/ui/playwright/utils/glossary.ts index 512c0a844d5..2e50f2a9728 100644 --- a/openmetadata-ui/src/main/resources/ui/playwright/utils/glossary.ts +++ b/openmetadata-ui/src/main/resources/ui/playwright/utils/glossary.ts @@ -10,7 +10,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { expect, Page } from '@playwright/test'; +import { APIRequestContext, expect, Page } from '@playwright/test'; import { get, isUndefined } from 'lodash'; import { SidebarItem } from '../constant/sidebar'; import { GLOSSARY_TERM_PATCH_PAYLOAD } from '../constant/version'; @@ -196,7 +196,7 @@ export const addTeamAsReviewer = async ( isSelectableInsideForm = false ) => { const teamsResponse = page.waitForResponse( - '/api/v1/search/query?q=*&from=0&size=*&index=team_search_index&sort_field=displayName.keyword&sort_order=asc' + '/api/v1/search/query?q=*&from=0&size=*&index=team_search_index&deleted=false&sort_field=displayName.keyword&sort_order=asc' ); const teamsSearchResponse = page.waitForResponse( @@ -1003,7 +1003,7 @@ export const createDescriptionTaskForGlossary = async ( await assigneeField.click(); const userSearchResponse = page.waitForResponse( - `/api/v1/search/query?q=*${value.assignee}**&index=user_search_index%2Cteam_search_index` + `/api/v1/search/query?q=*${value.assignee}**&index=user_search_index%2Cteam_search_index*` ); await assigneeField.fill(value.assignee); await userSearchResponse; @@ -1058,7 +1058,7 @@ export const createTagTaskForGlossary = async ( ); await assigneeField.click(); const userSearchResponse = page.waitForResponse( - `/api/v1/search/query?q=*${value.assignee}**&index=user_search_index%2Cteam_search_index` + `/api/v1/search/query?q=*${value.assignee}**&index=user_search_index%2Cteam_search_index*` ); await assigneeField.fill(value.assignee); await userSearchResponse; diff --git a/openmetadata-ui/src/main/resources/ui/playwright/utils/task.ts b/openmetadata-ui/src/main/resources/ui/playwright/utils/task.ts index f161970a415..464f1d8cf62 100644 --- a/openmetadata-ui/src/main/resources/ui/playwright/utils/task.ts +++ b/openmetadata-ui/src/main/resources/ui/playwright/utils/task.ts @@ -60,7 +60,7 @@ export const createDescriptionTask = async ( await assigneeField.click(); const userSearchResponse = page.waitForResponse( - `/api/v1/search/query?q=*${value.assignee}**&index=user_search_index%2Cteam_search_index` + `/api/v1/search/query?q=*${value.assignee}**&index=user_search_index%2Cteam_search_index*` ); await assigneeField.fill(value.assignee); @@ -113,7 +113,7 @@ export const createTagTask = async ( await assigneeField.click(); const userSearchResponse = page.waitForResponse( - `/api/v1/search/query?q=*${value.assignee}**&index=user_search_index%2Cteam_search_index` + `/api/v1/search/query?q=*${value.assignee}**&index=user_search_index%2Cteam_search_index*` ); await assigneeField.fill(value.assignee); await userSearchResponse; diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Explore/ExplorePage.interface.ts b/openmetadata-ui/src/main/resources/ui/src/components/Explore/ExplorePage.interface.ts index df979d03b51..ee51576c34c 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Explore/ExplorePage.interface.ts +++ b/openmetadata-ui/src/main/resources/ui/src/components/Explore/ExplorePage.interface.ts @@ -90,7 +90,7 @@ export interface ExploreProps { sortOrder: string; onChangeSortOder: (sortOder: SORT_ORDER) => void; - showDeleted: boolean; + showDeleted?: boolean; onChangeShowDeleted: (showDeleted: boolean) => void; onChangePage?: (page: number, size?: number) => void; diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/ExplorePage/ExplorePageV1.component.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/ExplorePage/ExplorePageV1.component.tsx index 0bf634592bc..a29758043aa 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/ExplorePage/ExplorePageV1.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/ExplorePage/ExplorePageV1.component.tsx @@ -11,7 +11,7 @@ * limitations under the License. */ -import { get, isEmpty, isNil, isString } from 'lodash'; +import { get, isEmpty, isNil, isString, omit } from 'lodash'; import Qs from 'qs'; import React, { FunctionComponent, @@ -217,8 +217,22 @@ const ExplorePageV1: FunctionComponent = () => { const handleShowDeletedChange: ExploreProps['onChangeShowDeleted'] = ( showDeleted ) => { + // Removed existing showDeleted from the parsedSearch object + const filteredParsedSearch = omit(parsedSearch, 'showDeleted'); + + // Set the default search object with page as 1 + const defaultSearchObject = { + ...filteredParsedSearch, + page: 1, + }; + + // If showDeleted is true, add it to the search object + const searchObject = showDeleted + ? { ...defaultSearchObject, showDeleted: true } + : defaultSearchObject; + history.push({ - search: Qs.stringify({ ...parsedSearch, showDeleted, page: 1 }), + search: Qs.stringify(searchObject), }); }; diff --git a/openmetadata-ui/src/main/resources/ui/src/utils/ExploreUtils.tsx b/openmetadata-ui/src/main/resources/ui/src/utils/ExploreUtils.tsx index b3e636e2ac3..6511312a247 100644 --- a/openmetadata-ui/src/main/resources/ui/src/utils/ExploreUtils.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/utils/ExploreUtils.tsx @@ -440,7 +440,9 @@ export const parseSearchParams = (search: string) => { ? Number.parseInt(parsedSearch.size) : PAGE_SIZE; - const showDeleted = parsedSearch.showDeleted === 'true'; + // We are not setting showDeleted as 'false' since we don't want it to conflict with + // the `Deleted` field value in the advanced search quick filters when the value there is true. + const showDeleted = parsedSearch.showDeleted === 'true' ? true : undefined; return { parsedSearch, @@ -526,7 +528,7 @@ export const fetchEntityData = async ({ updatedQuickFilters: QueryFilterInterface | undefined; queryFilter: unknown; searchIndex: ExploreSearchIndex; - showDeleted: boolean; + showDeleted?: boolean; sortValue: string; sortOrder: string; page: number; diff --git a/openmetadata-ui/src/main/resources/ui/src/utils/SearchUtils.tsx b/openmetadata-ui/src/main/resources/ui/src/utils/SearchUtils.tsx index 5bf0df43f67..1efc5cb2474 100644 --- a/openmetadata-ui/src/main/resources/ui/src/utils/SearchUtils.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/utils/SearchUtils.tsx @@ -73,12 +73,9 @@ export const getSearchAPIQueryParams = ( from: start, size, index: searchIndex, + deleted: onlyDeleted, }; - if (onlyDeleted) { - params.deleted = onlyDeleted; - } - if (!isEmpty(sortField)) { params.sort_field = sortField; }