Skip to content

Commit

Permalink
Add test cases for fp16, bf16, hybrid search
Browse files Browse the repository at this point in the history
Signed-off-by: ThreadDao <yufen.zong@zilliz.com>
  • Loading branch information
ThreadDao committed Apr 2, 2024
1 parent 7d66951 commit 799276b
Show file tree
Hide file tree
Showing 18 changed files with 1,077 additions and 165 deletions.
4 changes: 2 additions & 2 deletions examples/multivectors/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ func main() {

result, err = c.HybridSearch(ctx, collectionName, nil, topK, []string{keyCol, embeddingCol1, embeddingCol2},
client.NewRRFReranker(), []*client.ANNSearchRequest{
client.NewANNSearchRequest(embeddingCol1, entity.L2, vec2search1, sp, topK),
client.NewANNSearchRequest(embeddingCol2, entity.L2, vec2search2, sp, topK),
client.NewANNSearchRequest(embeddingCol1, entity.L2, "", vec2search1, sp, topK),
client.NewANNSearchRequest(embeddingCol2, entity.L2, "", vec2search2, sp, topK),
})
if err != nil {
log.Fatalf("failed to search collection, err: %v", err)
Expand Down
11 changes: 11 additions & 0 deletions test/base/milvus_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,17 @@ func (mc *MilvusClient) Search(ctx context.Context, collName string, partitions
return searchResult, err
}

func (mc *MilvusClient) HybridSearch(ctx context.Context, collName string, partitions []string, limit int, outputFields []string,
reranker client.Reranker, subRequests []*client.ANNSearchRequest) ([]client.SearchResult, error) {
funcName := "HybridSearch"
preRequest(funcName, ctx, collName, partitions, limit, outputFields, reranker, subRequests)

searchResult, err := mc.mClient.HybridSearch(ctx, collName, partitions, limit, outputFields, reranker, subRequests)
postResponse(funcName, err, searchResult)

return searchResult, err
}

// QueryByPks query from collection
func (mc *MilvusClient) QueryByPks(ctx context.Context, collName string, partitions []string, ids entity.Column,
outputFields []string, opts ...client.SearchQueryOptionFunc) (client.ResultSet, error) {
Expand Down
18 changes: 15 additions & 3 deletions test/common/response_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package common
import (
"fmt"
"log"
"strings"
"testing"

"github.com/milvus-io/milvus-sdk-go/v2/client"
Expand All @@ -15,11 +16,22 @@ func CheckErr(t *testing.T, actualErr error, expErrNil bool, expErrorMsg ...stri
if expErrNil {
require.NoError(t, actualErr)
} else {
if len(expErrorMsg) == 0 {
switch len(expErrorMsg) {
case 0:
log.Fatal("expect error message should not be empty")
case 1:
require.ErrorContains(t, actualErr, expErrorMsg[0])
default:
contains := false
for i := 0; i < len(expErrorMsg); i++ {
if strings.Contains(actualErr.Error(), expErrorMsg[i]) {
contains = true
}
}
if !contains {
t.FailNow()
}
}
require.NotEmpty(t, expErrorMsg[0])
require.ErrorContains(t, actualErr, expErrorMsg[0])
}
}

Expand Down
Loading

0 comments on commit 799276b

Please sign in to comment.