Support PUT /indexes/{name} for create-or-update (closes #30)#31
Merged
IndifferentDisdain merged 2 commits intomainfrom Apr 24, 2026
Merged
Support PUT /indexes/{name} for create-or-update (closes #30)#31IndifferentDisdain merged 2 commits intomainfrom
IndifferentDisdain merged 2 commits intomainfrom
Conversation
Adds a PUT handler that creates the index when absent and overwrites its schema when present, matching Azure AI Search's CreateOrUpdateIndex behavior so the Azure SDK's CreateOrUpdateIndexAsync works against the emulator. On update, cached Lucene reader/directory entries are cleared so schema changes take effect. Closes #30. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
PUT /indexes/{name}handler toIndexesControllerwith Azure-style create-or-update semantics: creates the index when absent (returns201 Created) and overwrites the schema when present (returns200 OK). This unblocksSearchIndexClient.CreateOrUpdateIndexAsync(...)from the Azure SDK, which previously got405 Method Not Allowed.index.Name(case-insensitive) and clears the cached Lucene reader/directory on update so schema changes take effect.UpdatetoISearchIndexRepositoryand a file-overwrite implementation inFileSearchIndexRepository.CreateOrUpdateIndexAsync: one for PUT-creates-new-index and one for PUT-updates-existing-with-added-field.Closes #30.
Test plan
dotnet build AzureSearchEmulator.sln— cleandotnet test AzureSearchEmulator.UnitTests— 108/108 passingdotnet test AzureSearchEmulator.IntegrationTests— 19/19 passing (17 existing + 2 new)🤖 Generated with Claude Code