Commit dd05046
committed
* fix(#27319): Add DB-backed /search endpoint for Roles and Teams
Add generic search infrastructure that enables server-side name/displayName
search via SQL LIKE queries, eliminating the need for large limit workarounds
in role/team selection dropdowns.
- EntityDAO: searchByNameAndDisplayName() with MySQL/Postgres support
- EntityRepository: search() with offset pagination and field resolution
- EntityResource: searchInternal() reusable by any entity resource
- RoleResource: GET /v1/roles/search?q=&limit=&offset=
- TeamResource: GET /v1/teams/search?q=&limit=&offset=
Co-Authored-By: sonika-shah <sonika-shah@users.noreply.github.com>
* test(#27319): Add integration tests for /search endpoint on Roles and Teams
Tests cover:
- Search by name (exact substring match)
- Search by displayName
- No results for non-matching query
- Offset-based pagination (page1, page2, page3)
- Empty query fallback to list
Co-Authored-By: sonika-shah <sonika-shah@users.noreply.github.com>
* test(#27319): Rewrite search integration tests as thorough end-to-end scenarios
Replace shallow per-behavior unit tests with comprehensive integration tests
that exercise the full search API in a single realistic flow:
- Create roles/teams with distinct name vs displayName to verify both paths
- Verify search finds matches by name AND displayName in one query
- Verify result ordering (by name)
- Verify no-match returns empty (not error)
- Walk full pagination (pages of 2 across 6 results, verify no duplicates)
- Verify fields param populates requested fields (policies, users)
- Verify soft-deleted entities are excluded from results
- Verify empty query falls back to listing
Co-Authored-By: sonika-shah <sonika-shah@users.noreply.github.com>
* test(#27319): Add case-insensitive search verification to integration tests
Verify that UPPERCASE, lowercase, and MiXeD case queries all return the
same results, ensuring the LOWER() SQL matching works correctly end-to-end.
Co-Authored-By: sonika-shah <sonika-shah@users.noreply.github.com>
* fix(#27319): Address review feedback — escape LIKE wildcards, remove empty-query branching
1. Escape SQL LIKE wildcards (%, _) in search term using ListFilter.escape()
to prevent unintended wildcard matching from user input.
2. Remove if/else branching in searchInternal — null/empty query now flows
through the same search() path (%% matches everything), so offset is
always respected. No separate fallback to listAfter needed.
Co-Authored-By: sonika-shah <sonika-shah@users.noreply.github.com>
* fix(#27319): Address Copilot review — domain filter, ResourceContext, ORDER BY tie-breaker
1. Use filter.getResourceContext() instead of bare ResourceContext for
consistent auth behavior with listInternal.
2. Add EntityUtil.addDomainQueryParam() so search respects domain restrictions.
3. Add id tie-breaker to ORDER BY (name, id) for deterministic pagination
when entities share the same name.
Co-Authored-By: sonika-shah <sonika-shah@users.noreply.github.com>
* refactor(#27319): Use ListFilter nameFilter instead of custom DAO query
Removes the custom searchByNameAndDisplayName SQL method from EntityDAO
and the search() method from EntityRepository. Instead, adds a
nameFilter condition to ListFilter.getCondition() — the LIKE clause
flows through the existing listAfter SQL, same as every other filter.
searchInternal now just sets filter.addQueryParam("nameFilter", query)
and delegates to listWithOffset, following the same offset-based
pagination pattern as GlossaryTermResource /search.
Co-Authored-By: sonika-shah <sonika-shah@users.noreply.github.com>
* fix(#27319): Remove duplicate addHref call in listWithOffset
listWithOffset was calling withHref on each entity, but the caller
(searchInternal) already calls addHref on the ResultList. Removed
the redundant call from listWithOffset.
Co-Authored-By: sonika-shah <sonika-shah@users.noreply.github.com>
* fix(#27319): Use dao.listCount for real total instead of approximate knownTotal
Same pattern as listAfter — one COUNT query per request gives the
exact total matching the filter, consistent with all other list endpoints.
Co-Authored-By: sonika-shah <sonika-shah@users.noreply.github.com>
* fix(#27319): Use unqualified name and json columns in nameFilter condition
Consistent with how other ListFilter conditions (getCreatedByCondition,
getEntityStatusCondition, getAgentTypeCondition) reference columns —
no table qualification needed for single-table queries.
Co-Authored-By: sonika-shah <sonika-shah@users.noreply.github.com>
* refactor: Extract shared listInternal in EntityRepository, fix GlossaryTerm offset pagination bug
- Extract listInternal() from listAfter() to share deserialize + setFieldsInBulk +
withHref logic between cursor-based and offset-based listing methods
- Add listAfterWithOffset() using the shared listInternal() for offset-based pagination
- Fix GlossaryTerm searchGlossaryTermsInternal: replace broken offset-to-cursor
conversion (raw offset passed to base64 cursor-based listAfter would crash for
offset > 0) with listAfterWithOffset
- searchInternal in EntityResource delegates to listAfterWithOffset
- Add integration test for GlossaryTerm /search with offset > 0 pagination
Co-Authored-By: sonika-shah <sonika-shah@users.noreply.github.com>
* fix: Use offset-based ResultList constructor and strengthen test assertions
- listAfterWithOffset uses ResultList(data, offset, limit, total) instead of
cursor-based constructor that was Base64-encoding offsets
- Paging response now returns plain offset/limit/total integers, consistent
with other offset-based APIs (e.g. listFromSearchWithOffset)
- Tests assert paging.offset and paging.total instead of paging.after
- TeamResourceIT creates team with users and policies to properly verify
fields param populates requested fields
Co-Authored-By: sonika-shah <sonika-shah@users.noreply.github.com>
* scope: Remove teams /search endpoint — this PR is roles only
Teams search will be added in a follow-up PR. Removed /search endpoint
from TeamResource and all search-related tests from TeamResourceIT.
Co-Authored-By: sonika-shah <sonika-shah@users.noreply.github.com>
* fix: Remove unnecessary limit+1 fetch in listAfterWithOffset
Since listCount already provides exact total, we don't need to fetch
an extra row to detect has-more. Just fetch exactly limit rows.
Co-Authored-By: sonika-shah <sonika-shah@users.noreply.github.com>
---------
Co-authored-by: sonika-shah <sonika-shah@users.noreply.github.com>
(cherry picked from commit e49b572)
1 parent 6a3af1e commit dd05046
7 files changed
Lines changed: 335 additions & 26 deletions
File tree
- openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests
- openmetadata-service/src/main/java/org/openmetadata/service
- jdbi3
- resources
- teams
openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/GlossaryTermResourceIT.java
Lines changed: 51 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2667 | 2667 | | |
2668 | 2668 | | |
2669 | 2669 | | |
| 2670 | + | |
| 2671 | + | |
| 2672 | + | |
| 2673 | + | |
| 2674 | + | |
| 2675 | + | |
| 2676 | + | |
| 2677 | + | |
| 2678 | + | |
| 2679 | + | |
| 2680 | + | |
| 2681 | + | |
| 2682 | + | |
| 2683 | + | |
| 2684 | + | |
| 2685 | + | |
| 2686 | + | |
| 2687 | + | |
| 2688 | + | |
| 2689 | + | |
| 2690 | + | |
| 2691 | + | |
| 2692 | + | |
| 2693 | + | |
| 2694 | + | |
| 2695 | + | |
| 2696 | + | |
| 2697 | + | |
| 2698 | + | |
| 2699 | + | |
| 2700 | + | |
| 2701 | + | |
| 2702 | + | |
| 2703 | + | |
| 2704 | + | |
| 2705 | + | |
| 2706 | + | |
| 2707 | + | |
| 2708 | + | |
| 2709 | + | |
| 2710 | + | |
| 2711 | + | |
| 2712 | + | |
| 2713 | + | |
| 2714 | + | |
| 2715 | + | |
| 2716 | + | |
| 2717 | + | |
| 2718 | + | |
| 2719 | + | |
| 2720 | + | |
2670 | 2721 | | |
2671 | 2722 | | |
2672 | 2723 | | |
| |||
Lines changed: 168 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| 37 | + | |
| 38 | + | |
36 | 39 | | |
37 | 40 | | |
38 | 41 | | |
| |||
370 | 373 | | |
371 | 374 | | |
372 | 375 | | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
373 | 541 | | |
374 | 542 | | |
375 | 543 | | |
| |||
Lines changed: 23 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1981 | 1981 | | |
1982 | 1982 | | |
1983 | 1983 | | |
1984 | | - | |
1985 | | - | |
1986 | | - | |
1987 | | - | |
1988 | | - | |
1989 | | - | |
1990 | | - | |
1991 | | - | |
1992 | | - | |
1993 | | - | |
| 1984 | + | |
1994 | 1985 | | |
1995 | 1986 | | |
1996 | 1987 | | |
| |||
2007 | 1998 | | |
2008 | 1999 | | |
2009 | 2000 | | |
| 2001 | + | |
| 2002 | + | |
| 2003 | + | |
| 2004 | + | |
| 2005 | + | |
| 2006 | + | |
| 2007 | + | |
| 2008 | + | |
| 2009 | + | |
| 2010 | + | |
| 2011 | + | |
| 2012 | + | |
| 2013 | + | |
| 2014 | + | |
| 2015 | + | |
| 2016 | + | |
| 2017 | + | |
| 2018 | + | |
| 2019 | + | |
| 2020 | + | |
| 2021 | + | |
| 2022 | + | |
2010 | 2023 | | |
2011 | 2024 | | |
2012 | 2025 | | |
| |||
Lines changed: 2 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2486 | 2486 | | |
2487 | 2487 | | |
2488 | 2488 | | |
2489 | | - | |
| 2489 | + | |
2490 | 2490 | | |
2491 | 2491 | | |
2492 | 2492 | | |
| |||
2496 | 2496 | | |
2497 | 2497 | | |
2498 | 2498 | | |
2499 | | - | |
2500 | | - | |
2501 | | - | |
2502 | | - | |
2503 | | - | |
2504 | | - | |
2505 | | - | |
2506 | | - | |
2507 | | - | |
2508 | | - | |
2509 | | - | |
2510 | | - | |
2511 | | - | |
2512 | | - | |
2513 | | - | |
| 2499 | + | |
2514 | 2500 | | |
2515 | 2501 | | |
2516 | 2502 | | |
| |||
Lines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
76 | 77 | | |
77 | 78 | | |
78 | 79 | | |
| |||
755 | 756 | | |
756 | 757 | | |
757 | 758 | | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
758 | 775 | | |
759 | 776 | | |
760 | 777 | | |
| |||
Lines changed: 24 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
242 | 242 | | |
243 | 243 | | |
244 | 244 | | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
245 | 269 | | |
246 | 270 | | |
247 | 271 | | |
| |||
0 commit comments