-
Couldn't load subscription status.
- Fork 1
revert AI some suggestions for they break if search index initially does not exist #350
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
base: main
Are you sure you want to change the base?
Conversation
Reviewer's Guide by SourceryThis PR reverts some AI suggestions that caused breaks if the search index did not initially exist. It modifies the Azure Cognitive Search implementation to handle missing indexes more gracefully and updates the InfrastructureServicesBuilder to initialize search clients asynchronously. Sequence diagram for updated Azure Cognitive Search initializationsequenceDiagram
participant App
participant Builder as InfrastructureServicesBuilder
participant Search as AzCognitiveSearch
participant Azure as Azure Services
App->>Builder: initialize()
activate Builder
Builder->>Search: new AzCognitiveSearch(endpoint)
activate Search
Search->>Azure: create DefaultAzureCredential
Search->>Azure: create SearchIndexClient
Search-->>Builder: return instance
deactivate Search
Builder->>Search: initializeSearchClients()
activate Search
Search->>Azure: listIndexesNames()
Azure-->>Search: existing indexes
loop For each index
Search->>Search: set searchClient in Map
end
Search-->>Builder: void
deactivate Search
Builder-->>App: void
deactivate Builder
Class diagram for updated Cognitive Search interfacesclassDiagram
class CognitiveSearchBase {
<<interface>>
+createIndex(indexDefinition: SearchIndex)
+createOrUpdateIndex(indexName: string, indexDefinition: SearchIndex)
+search(indexName: string, searchText: string, options?: any)
+deleteDocument(indexName: string, document: any)
+indexDocument(indexName: string, document: any)
+deleteIndex(indexName: string)
+indexExists(indexName: string) boolean
+initializeSearchClients() Promise~void~
}
class AzCognitiveSearch {
-client: SearchIndexClient
-searchClients: Map
+constructor(endpoint: string)
+initializeSearchClients()
+indexExists(indexName: string)
+createIndex(indexDefinition: SearchIndex)
+search(indexName: string, searchText: string, options?: any)
}
CognitiveSearchBase <|.. AzCognitiveSearch
note for AzCognitiveSearch "Modified to handle missing indexes
and initialize clients asynchronously"
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey @nguyenduy - I've reviewed your changes - here's some feedback:
Overall Comments:
- The change from async indexExists() to sync indexExists() is a breaking change that could affect existing code. Consider either keeping the async version for backward compatibility or documenting this change prominently for users of the library.
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟢 Review instructions: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
gp |
|
diff |
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.
gp
diff
Summary by Sourcery
Initialize search clients during application startup to ensure they are available when needed.
Bug Fixes:
Enhancements: