Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor : Fix exception in search due to exception in database.displayN… #18290

Merged
merged 2 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1297,6 +1297,23 @@ private static SearchSourceBuilder buildSearchAcrossIndexesBuilder(
buildSearchQueryBuilder(query, SearchIndex.getAllFields());
FunctionScoreQueryBuilder queryBuilder = boostScore(queryStringBuilder);
SearchSourceBuilder searchSourceBuilder = searchBuilder(queryBuilder, null, from, size);
searchSourceBuilder.aggregation(
AggregationBuilders.terms("database.name.keyword")
.field("database.name.keyword")
.size(MAX_AGGREGATE_SIZE));
searchSourceBuilder.aggregation(
AggregationBuilders.terms("databaseSchema.name.keyword")
.field("databaseSchema.name.keyword")
.size(MAX_AGGREGATE_SIZE));
return addAggregation(searchSourceBuilder);
Comment on lines +1301 to +1308
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we do the aggregation on the fullyQualifiedName? Using name I believe if we have service.database.schema and otherService.database.schema then they'll both get aggregated under the same if we use name I believe.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @TeddyCr thanks for pointing your concern is valid, but for our usage we are not dependent
only on a single aggregation while getting result, we check the condition with other aggregations as well
image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have tried to replicate the same scenario with same database and schema, seems to be working fine.
Also will be removing the support for aggregations on name.keyword, as in most scenario we are moving to show results based on displayName

image

}

private static SearchSourceBuilder buildDataAssetsSearchBuilder(
String query, int from, int size) {
QueryStringQueryBuilder queryStringBuilder =
buildSearchQueryBuilder(query, SearchIndex.getAllFields());
FunctionScoreQueryBuilder queryBuilder = boostScore(queryStringBuilder);
SearchSourceBuilder searchSourceBuilder = searchBuilder(queryBuilder, null, from, size);
searchSourceBuilder.aggregation(
AggregationBuilders.terms("database.name.keyword")
.field("database.name.keyword")
Expand Down Expand Up @@ -2310,7 +2327,8 @@ private static SearchSourceBuilder getSearchSourceBuilder(
"storage_service_index",
"search_service_index",
"metadata_service_index" -> buildServiceSearchBuilder(q, from, size);
case "all", "dataAsset" -> buildSearchAcrossIndexesBuilder(q, from, size);
case "dataAsset" -> buildDataAssetsSearchBuilder(q, from, size);
case "all" -> buildSearchAcrossIndexesBuilder(q, from, size);
default -> buildAggregateSearchBuilder(q, from, size);
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1282,6 +1282,24 @@ private static SearchSourceBuilder buildSearchAcrossIndexesBuilder(
FunctionScoreQueryBuilder queryBuilder = boostScore(queryStringBuilder);
queryBuilder.boostMode(CombineFunction.SUM);
SearchSourceBuilder searchSourceBuilder = searchBuilder(queryBuilder, null, from, size);
searchSourceBuilder.aggregation(
AggregationBuilders.terms("database.name.keyword")
.field("database.name.keyword")
.size(MAX_AGGREGATE_SIZE));
searchSourceBuilder.aggregation(
AggregationBuilders.terms("databaseSchema.name.keyword")
.field("databaseSchema.name.keyword")
.size(MAX_AGGREGATE_SIZE));
return addAggregation(searchSourceBuilder);
Comment on lines +1285 to +1293
Copy link
Contributor

@TeddyCr TeddyCr Oct 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

private static SearchSourceBuilder buildDataAssetsSearchBuilder(
String query, int from, int size) {
QueryStringQueryBuilder queryStringBuilder =
buildSearchQueryBuilder(query, SearchIndex.getAllFields());
FunctionScoreQueryBuilder queryBuilder = boostScore(queryStringBuilder);
queryBuilder.boostMode(CombineFunction.SUM);
SearchSourceBuilder searchSourceBuilder = searchBuilder(queryBuilder, null, from, size);
searchSourceBuilder.aggregation(
AggregationBuilders.terms("database.name.keyword")
.field("database.name.keyword")
Expand Down Expand Up @@ -2288,7 +2306,8 @@ private static SearchSourceBuilder getSearchSourceBuilder(
"storage_service_index",
"search_service_index",
"metadata_service_index" -> buildServiceSearchBuilder(q, from, size);
case "all", "dataAsset" -> buildSearchAcrossIndexesBuilder(q, from, size);
case "dataAsset" -> buildDataAssetsSearchBuilder(q, from, size);
case "all" -> buildSearchAcrossIndexesBuilder(q, from, size);
default -> buildAggregateSearchBuilder(q, from, size);
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,10 @@
"type": "text"
}
}
},
"serviceType": {
"type": "keyword",
"normalizer": "lowercase_normalizer"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,10 @@
}
}
},
"serviceType": {
"type": "keyword",
"normalizer": "lowercase_normalizer"
},
"totalVotes": {
"type": "long",
"null_value": 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,10 @@
}
}
},
"serviceType": {
"type": "keyword",
"normalizer": "lowercase_normalizer"
},
"totalVotes": {
"type": "long",
"null_value": 0
Expand Down
Loading