Skip to content

Commit f6da290

Browse files
gitar-botCopilot
andcommitted
Fix backend search and remove dead code
Critical fixes from code review: - Add missing @QueryParam("q") String query parameter to LearningResourceResource.list() - Pass query parameter to filter so backend search actually works - Remove dead code: pageCondition() and categoryCondition() methods (replaced by pageIdsCondition and categoriesCondition) Backend search was previously broken - the frontend sent 'q' parameter but backend never declared or used it, silently ignoring all search requests. Co-authored-by: Copilot <Copilot@users.noreply.github.com>
1 parent babf6c1 commit f6da290

File tree

2 files changed

+18
-34
lines changed

2 files changed

+18
-34
lines changed

openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/LearningResourceRepository.java

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -288,18 +288,6 @@ private String jsonColumn(String tableName) {
288288
return tableName == null ? "json" : tableName + ".json";
289289
}
290290

291-
private String pageCondition(String tableName) {
292-
String column = jsonColumn(tableName);
293-
if (Boolean.TRUE.equals(DatasourceConfig.getInstance().isMySQL())) {
294-
return String.format(
295-
"JSON_SEARCH(%s, 'one', :pageId, NULL, '$.contexts[*].pageId') IS NOT NULL", column);
296-
}
297-
return String.format(
298-
"EXISTS (SELECT 1 FROM jsonb_array_elements(COALESCE(%s->'contexts', '[]'::jsonb)) ctx"
299-
+ " WHERE ctx->>'pageId' = :pageId)",
300-
column);
301-
}
302-
303291
private String componentCondition(String tableName) {
304292
String column = jsonColumn(tableName);
305293
if (Boolean.TRUE.equals(DatasourceConfig.getInstance().isMySQL())) {
@@ -313,18 +301,6 @@ private String componentCondition(String tableName) {
313301
column);
314302
}
315303

316-
private String categoryCondition(String tableName) {
317-
String column = jsonColumn(tableName);
318-
if (Boolean.TRUE.equals(DatasourceConfig.getInstance().isMySQL())) {
319-
return String.format(
320-
"JSON_SEARCH(%s, 'one', :category, NULL, '$.categories') IS NOT NULL", column);
321-
}
322-
return String.format(
323-
"EXISTS (SELECT 1 FROM jsonb_array_elements_text(COALESCE(%s->'categories', '[]'::jsonb)) cat"
324-
+ " WHERE cat = :category)",
325-
column);
326-
}
327-
328304
private String difficultyCondition(String tableName) {
329305
String column = jsonColumn(tableName);
330306
if (Boolean.TRUE.equals(DatasourceConfig.getInstance().isMySQL())) {

openmetadata-service/src/main/java/org/openmetadata/service/resources/learning/LearningResourceResource.java

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,17 +128,22 @@ public ResultList<LearningResource> list(
128128
@Parameter(description = "Returns list of learning resources after this cursor")
129129
@QueryParam("after")
130130
String after,
131-
@Parameter(
132-
description = "Include all, deleted, or non-deleted entities",
133-
schema = @Schema(implementation = Include.class))
134-
@QueryParam("include")
135-
@DefaultValue("non-deleted")
136-
Include include,
137131
@Parameter(
138-
description = "Filter resources to specific page identifiers (supports multiple values)",
139-
schema = @Schema(type = "array"))
140-
@QueryParam("pageId")
141-
List<String> pageIds,
132+
description = "Include all, deleted, or non-deleted entities",
133+
schema = @Schema(implementation = Include.class))
134+
@QueryParam("include")
135+
@DefaultValue("non-deleted")
136+
Include include,
137+
@Parameter(
138+
description = "Search query for text search across name, displayName, and description",
139+
schema = @Schema(type = "string"))
140+
@QueryParam("q")
141+
String query,
142+
@Parameter(
143+
description = "Filter resources to specific page identifiers (supports multiple values)",
144+
schema = @Schema(type = "array"))
145+
@QueryParam("pageId")
146+
List<String> pageIds,
142147
@Parameter(
143148
description = "Filter by component identifier within a page",
144149
schema = @Schema(type = "string"))
@@ -166,6 +171,9 @@ public ResultList<LearningResource> list(
166171
List<String> statuses) {
167172
LearningResourceRepository.LearningResourceFilter filter =
168173
new LearningResourceRepository.LearningResourceFilter(include);
174+
if (query != null && !query.isEmpty()) {
175+
filter.addQueryParam("q", query);
176+
}
169177
if (pageIds != null && !pageIds.isEmpty()) {
170178
filter.addQueryParam("pageIds", pageIds);
171179
}

0 commit comments

Comments
 (0)