Skip to content

Commit

Permalink
[add] v1.4 v1.6 and v2.0 working as expected on features present acro…
Browse files Browse the repository at this point in the history
…ss versions
  • Loading branch information
filipecosta90 committed Aug 8, 2020
1 parent 980f307 commit 9708884
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 23 deletions.
40 changes: 20 additions & 20 deletions redisearch/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@ package redisearch

import "github.com/gomodule/redigo/redis"

// IndexInfo - Structure showing information about an existing index
type IndexInfo struct {
Schema Schema
Name string `redis:"index_name"`
DocCount uint64 `redis:"num_docs"`
RecordCount uint64 `redis:"num_records"`
TermCount uint64 `redis:"num_terms"`
MaxDocID uint64 `redis:"max_doc_id"`
InvertedIndexSizeMB float64 `redis:"inverted_sz_mb"`
OffsetVectorSizeMB float64 `redis:"offset_vector_sz_mb"`
DocTableSizeMB float64 `redis:"doc_table_size_mb"`
KeyTableSizeMB float64 `redis:"key_table_size_mb"`
RecordsPerDocAvg float64 `redis:"records_per_doc_avg"`
BytesPerRecordAvg float64 `redis:"bytes_per_record_avg"`
OffsetsPerTermAvg float64 `redis:"offsets_per_term_avg"`
OffsetBitsPerTermAvg float64 `redis:"offset_bits_per_record_avg"`
IsIndexing bool `redis:"indexing"`
PercentIndexed float64 `redis:"percent_indexed"`
}

func SerializeIndexingOptions(opts IndexingOptions, args redis.Args) redis.Args {
// apply options
if opts.NoSave {
Expand All @@ -26,23 +46,3 @@ func SerializeIndexingOptions(opts IndexingOptions, args redis.Args) redis.Args
}
return args
}

// IndexInfo - Structure showing information about an existing index
type IndexInfo struct {
Schema Schema
Name string `redis:"index_name"`
DocCount uint64 `redis:"num_docs"`
RecordCount uint64 `redis:"num_records"`
TermCount uint64 `redis:"num_terms"`
MaxDocID uint64 `redis:"max_doc_id"`
InvertedIndexSizeMB float64 `redis:"inverted_sz_mb"`
OffsetVectorSizeMB float64 `redis:"offset_vector_sz_mb"`
DocTableSizeMB float64 `redis:"doc_table_size_mb"`
KeyTableSizeMB float64 `redis:"key_table_size_mb"`
RecordsPerDocAvg float64 `redis:"records_per_doc_avg"`
BytesPerRecordAvg float64 `redis:"bytes_per_record_avg"`
OffsetsPerTermAvg float64 `redis:"offsets_per_term_avg"`
OffsetBitsPerTermAvg float64 `redis:"offset_bits_per_record_avg"`
IsIndexing bool `redis:"indexing"`
PercentIndexed float64 `redis:"percent_indexed"`
}
15 changes: 12 additions & 3 deletions redisearch/redisearch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,17 @@ func TestClient(t *testing.T) {
}
}

docs, _, err := c.Search(NewQuery("hello world"))
// Wait for all documents to be indexed
info, _ := c.Info()
for info.IsIndexing {
time.Sleep(time.Second)
info, _ = c.Info()
}

docs, total, err := c.Search(NewQuery("hello world"))
assert.Nil(t, err)
assert.Equal(t, 100, total)
assert.Equal(t, 10, len(docs))
teardown(c)
}

Expand Down Expand Up @@ -364,7 +373,7 @@ func TestDelete(t *testing.T) {
// validate that the index is empty
info, err = c.Info()
assert.Nil(t, err)
if info.IsIndexing == false {
if !info.IsIndexing {
assert.Equal(t, uint64(0), info.DocCount)
}

Expand All @@ -377,7 +386,7 @@ func TestDelete(t *testing.T) {
// now we should have 1 document (id = doc1)
info, err = c.Info()
assert.Nil(t, err)
if info.IsIndexing == false {
if !info.IsIndexing {
assert.Equal(t, uint64(1), info.DocCount)
}

Expand Down

0 comments on commit 9708884

Please sign in to comment.