-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Make Selective Field Query during Reindexing #27723
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
Changes from all commits
2c86134
2a070b0
c4351c8
0b7d606
205b942
ef4cc58
dcb2fef
de3897a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -107,6 +107,28 @@ | |
| @Slf4j | ||
| public class SearchIndexFactory { | ||
|
|
||
| /** | ||
| * Returns the minimal set of fields the reindex path must request from | ||
| * {@code EntityRepository.setFields} for the given entity type. Probes the corresponding | ||
| * index class via {@link #buildIndex(String, Object)} with a {@code null} entity and calls | ||
| * {@link SearchIndex#getRequiredReindexFields()}. Index constructors must be safe with a null | ||
| * entity for this probe to work — they are today because field declarations are static. | ||
| */ | ||
| public java.util.Set<String> getReindexFieldsFor(String entityType) { | ||
| try { | ||
| SearchIndex probe = buildIndex(entityType, null); | ||
| if (probe != null) { | ||
| return probe.getRequiredReindexFields(); | ||
| } | ||
| } catch (Exception e) { | ||
| LOG.warn( | ||
| "Failed to probe reindex fields for entity type {}; falling back to common set: {}", | ||
| entityType, | ||
| e.getMessage()); | ||
| } | ||
| return SearchIndex.COMMON_REINDEX_FIELDS; | ||
|
Comment on lines
+123
to
+129
|
||
| } | ||
|
mohityadav766 marked this conversation as resolved.
Comment on lines
+110
to
+130
|
||
|
|
||
| public SearchIndex buildIndex(String entityType, Object entity) { | ||
| return switch (entityType) { | ||
| case Entity.TABLE -> new TableIndex((Table) entity); | ||
|
|
@@ -177,7 +199,9 @@ public SearchIndex buildIndex(String entityType, Object entity) { | |
| case Entity.PIPELINE_EXECUTION -> { | ||
| PipelineExecutionIndex.PipelineExecutionData data = | ||
| (PipelineExecutionIndex.PipelineExecutionData) entity; | ||
| yield new PipelineExecutionIndex(data.getPipeline(), data.getPipelineStatus()); | ||
| yield data == null | ||
| ? new PipelineExecutionIndex(null, null) | ||
| : new PipelineExecutionIndex(data.getPipeline(), data.getPipelineStatus()); | ||
| } | ||
| default -> buildExternalIndexes(entityType, entity); | ||
| }; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The catch block logs only
e.getMessage()and drops the exception/stack trace, which can make it hard to diagnose why probing failed (especially ifgetMessage()is null). Consider logging the exception itself (e.g., as the last argument) so failures in field probing are actionable.