Fix #1563: Filter by database name (#1580)

This commit is contained in:
Sriharsha Chintalapani 2021-12-06 12:17:24 -08:00 committed by GitHub
parent 4943bd24ed
commit ddf4f13c22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 13 deletions

View File

@ -14,12 +14,6 @@
package org.openmetadata.catalog.resources.search;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder;
import org.elasticsearch.search.suggest.Suggest;
import org.elasticsearch.search.suggest.SuggestBuilder;
@ -32,11 +26,9 @@ import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import org.apache.http.HttpHost;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.index.query.QueryBuilders;
@ -79,7 +71,7 @@ public class SearchResource {
description = "Search entities using query test. Use query params `from` and `size` for pagination. Use " +
"`sort_field` to sort the results in `sort_order`.",
responses = {
@ApiResponse(responseCode = "200", description = "search response",
@ApiResponse(responseCode = "200", description = "search response",
content = @Content(mediaType = "application/json",
schema = @Schema(implementation = SearchResponse.class)))
})
@ -148,7 +140,7 @@ public class SearchResource {
@Operation(summary = "Suggest entities", tags = "search",
description = "Get suggested entities used for auto-completion.",
responses = {
@ApiResponse(responseCode = "200",
@ApiResponse(responseCode = "200",
description = "Table Suggestion API",
content = @Content(mediaType = "application/json",
schema = @Schema(implementation = SearchResponse.class)))
@ -225,10 +217,11 @@ public class SearchResource {
.aggregation(AggregationBuilders.terms("EntityType").field("entity_type"))
.aggregation(AggregationBuilders.terms("Tier").field("tier"))
.aggregation(AggregationBuilders.terms("Tags").field("tags"))
.aggregation(AggregationBuilders.terms("Database").field("database"))
.highlighter(hb)
.from(from).size(size);
return searchSourceBuilder;
return searchSourceBuilder;
}
private SearchSourceBuilder buildTopicSearchBuilder(String query, int from, int size) {

View File

@ -47,7 +47,7 @@
"type": "keyword"
},
"database": {
"type": "text"
"type": "keyword"
},
"suggest": {
"type": "completion"

View File

@ -63,7 +63,7 @@ TABLE_ELASTICSEARCH_INDEX_MAPPING = textwrap.dedent(
"type": "keyword"
},
"database": {
"type": "text"
"type": "keyword"
},
"suggest": {
"type": "completion"