MCPcopy
hub / github.com/redis/go-redis / WaitForIndexing

Function WaitForIndexing

search_test.go:23–36  ·  view source on GitHub ↗

WaitForIndexing polls FT.INFO until the index has finished both its initial indexing pass and any background cleaning. Cleaning can briefly report 1 right after index creation (e.g. for HNSW vector indexes) while background setup is in progress, so callers that immediately assert on FT.INFO fields w

(c *redis.Client, index string)

Source from the content-addressed store, hash-verified

21// background setup is in progress, so callers that immediately assert on
22// FT.INFO fields would otherwise be flaky.
23func WaitForIndexing(c *redis.Client, index string) {
24 deadline := time.Now().Add(30 * time.Second)
25 for {
26 res, err := c.FTInfo(context.Background(), index).Result()
27 Expect(err).NotTo(HaveOccurred())
28 if res.Indexing == 0 && res.Cleaning == 0 {
29 return
30 }
31 if time.Now().After(deadline) {
32 Fail(fmt.Sprintf("WaitForIndexing(%q) timed out: indexing=%d cleaning=%d", index, res.Indexing, res.Cleaning))
33 }
34 time.Sleep(100 * time.Millisecond)
35 }
36}
37
38func encodeFloat32Vector(vec []float32) []byte {
39 buf := new(bytes.Buffer)

Callers 3

search_test.goFile · 0.85

Calls 3

AddMethod · 0.65
ResultMethod · 0.65
FTInfoMethod · 0.65

Tested by

no test coverage detected