fix(search): refresh the index after a write

This commit is contained in:
Florian Schade committed 2026-08-21 10:03:52 +02:00
1 parent 3b47c6550d
commit 97a8be52d2
4 files changed
+28 -2

No files matched your search

@@ -214,6 +214,29 @@ var _ = Describe("Backend", func() {
})
})
Describe("WriteVisibility", func() {
const indexName = "opencloud-test-engine-write-visibility"
It("deletes a record that was just written", func() {
document := opensearchtest.Testdata.Resources.File
document.ID = "1$1!95"
document.Name = "textfile.txt"
document.Path = "./textfile.txt"
backend, tc := newBackend(indexName)
deleteIndexOnCleanup(tc, indexName)
Expect(backend.Upsert(document.ID, document)).To(Succeed())
Expect(backend.Delete(document.ID)).To(Succeed())
resp, err := backend.Search(context.Background(), &searchService.SearchIndexRequest{
Query: fmt.Sprintf(`name:"%s"`, document.Name),
})
Expect(err).ToNot(HaveOccurred())
Expect(resp.Matches).To(BeEmpty())
})
})
Describe("Delete", func() {
const indexName = "opencloud-test-engine-delete"
+3 -1
View File
@@ -158,6 +158,7 @@ func (b *Batch) Purge(id string, onlyDeleted bool) error {
Indices: []string{b.index},
Params: opensearchgoAPI.DocumentDeleteByQueryParams{
WaitForCompletion: conversions.ToPointer(true),
Refresh: conversions.ToPointer(true),
},
},
query,
@@ -210,7 +211,8 @@ func (b *Batch) Push() error {
}
if _, err := b.client.Bulk(context.Background(), opensearchgoAPI.BulkReq{
Body: strings.NewReader(body.String()),
Body: strings.NewReader(body.String()),
Params: opensearchgoAPI.BulkParams{Refresh: "wait_for"},
}); err != nil {
return fmt.Errorf("failed to execute bulk operations: %w", err)
}
@@ -54,6 +54,7 @@ func updateSelfAndDescendants(ctx context.Context, client *opensearchgoAPI.Clien
Indices: []string{index},
Params: opensearchgoAPI.UpdateByQueryParams{
WaitForCompletion: conversions.ToPointer(true),
Refresh: conversions.ToPointer(true),
},
},
osu.NewBoolQuery().
@@ -114,7 +114,7 @@ Feature: search for favorites
Then the HTTP status code should be "207"
And the search result should contain "0" entries
@issue-3309
Scenario: search for favorite files after deleting a file
Given user "Alice" has uploaded file "filesForUpload/textfile.txt" to "textfile.txt"
And user "Alice" has marked file "textfile.txt" as favorite from space "Personal"