perf(graphql): align concept search with REST and add Elasticsearch safe-path #816
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR delivers significant performance optimizations for concept search via GraphQL by introducing a safe path that queries Elasticsearch directly for simple requests, with the explicit goal of making the GraphQL search behavior and result experience as close as possible to the REST search. It also fixes ID list lookup, and improves test coverage and documentation.
Key Changes
🚀 Performance & Optimization
is_optimization_safe) to detect when a GraphQL query requests only fields available in the Elasticsearch index (e.g.,id,display,conceptClass,datatype,metadata).serialize_es_hit), avoiding expensive PostgreSQL queries and preventing N+1 query issues.🐛 Bug Fixes
concepts_for_ids): Implemented the missing helper to resolve queries based on a list ofconceptIds.auth_statuscheck in the main resolver to avoid errors when the attribute is absent from the request context.🛠️ Refactoring & Code Quality
core/graphql/queries.py.Impacted Files
core/graphql/queries.py: Main resolver logic, optimization, and serialization.core/graphql/tests/*: New test cases and updates to existing tests.core/settings.py: Minor configuration adjustments.Tests