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)
| 21 | // background setup is in progress, so callers that immediately assert on |
| 22 | // FT.INFO fields would otherwise be flaky. |
| 23 | func 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 | |
| 38 | func encodeFloat32Vector(vec []float32) []byte { |
| 39 | buf := new(bytes.Buffer) |
no test coverage detected