Skip to content

Commit

Permalink
Prefix storage index values with 'value.'
Browse files Browse the repository at this point in the history
  • Loading branch information
sesposito committed Aug 22, 2023
1 parent 2d76ca2 commit 259f432
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion server/storage_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ LIMIT $2`
if err != nil {
return err
}
defer rows.Close()

var rowsRead bool
batch := bluge.NewBatch()
Expand Down Expand Up @@ -338,6 +339,7 @@ LIMIT $2`

doc, err := si.mapIndexStorageFields(dbUserID.String(), idx.Collection, dbKey, dbVersion, dbValue, idx.Fields, dbUpdateTime.Time)
if err != nil {
rows.Close()
si.logger.Error("Failed to map storage object values to index", zap.Error(err))
return err
}
Expand Down Expand Up @@ -417,7 +419,7 @@ func (si *LocalStorageIndex) mapIndexStorageFields(userID, collection, key, vers
rv.AddField(bluge.NewKeywordField("user_id", userID).StoreValue())
rv.AddField(bluge.NewKeywordField("version", version).StoreValue())

BlugeWalkDocument(mapValue, []string{}, rv)
BlugeWalkDocument(mapValue, []string{"value"}, rv)

return rv, nil
}
Expand Down
4 changes: 2 additions & 2 deletions server/storage_index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func TestLocalStorageIndex_Write(t *testing.T) {
t.Fatal(err.Error())
}

entries, err := storageIdx.List(ctx, indexName1, "+three:3", maxEntries1)
entries, err := storageIdx.List(ctx, indexName1, "+value.three:3", maxEntries1)
if err != nil {
t.Fatal(err.Error())
}
Expand Down Expand Up @@ -362,7 +362,7 @@ func TestLocalStorageIndex_List(t *testing.T) {
t.Fatal(err.Error())
}

entries, err := storageIdx.List(ctx, indexName, "one:1 three:3", 10)
entries, err := storageIdx.List(ctx, indexName, "value.one:1 value.three:3", 10)
if err != nil {
t.Fatal(err.Error())
}
Expand Down

0 comments on commit 259f432

Please sign in to comment.