Skip to content

Commit

Permalink
Fix hybrid search case and response check
Browse files Browse the repository at this point in the history
Signed-off-by: Congqi Xia <[email protected]>
  • Loading branch information
congqixia committed Apr 10, 2024
1 parent e1a56c6 commit 20a8014
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions test/common/response_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ func CheckErr(t *testing.T, actualErr error, expErrNil bool, expErrorMsg ...stri
if expErrNil {
require.NoError(t, actualErr)
} else {
require.Error(t, actualErr)
switch len(expErrorMsg) {
case 0:
log.Fatal("expect error message should not be empty")
Expand Down
8 changes: 5 additions & 3 deletions test/testcases/hybrid_search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package testcases

import (
"fmt"
"log"
"testing"
"time"

Expand Down Expand Up @@ -188,17 +189,18 @@ func TestHybridSearchInvalidVectors(t *testing.T) {
// hybrid search with invalid limit
ranker := client.NewRRFReranker()
sp, _ := entity.NewIndexFlatSearchParam()
queryVecNq := common.GenSearchVectors(common.DefaultNq, common.DefaultDim, entity.FieldTypeFloatVector)
// queryVecNq := common.GenSearchVectors(common.DefaultNq, common.DefaultDim, entity.FieldTypeFloatVector)
queryVecBinary := common.GenSearchVectors(1, common.DefaultDim, entity.FieldTypeBinaryVector)
queryVecType := common.GenSearchVectors(1, common.DefaultDim, entity.FieldTypeFloat16Vector)
queryVecDim := common.GenSearchVectors(1, common.DefaultDim*2, entity.FieldTypeFloatVector)
sReqs := [][]*client.ANNSearchRequest{
{client.NewANNSearchRequest(common.DefaultFloatVecFieldName, entity.L2, "", queryVecNq, sp, common.DefaultTopK)}, // nq != 1
// {client.NewANNSearchRequest(common.DefaultFloatVecFieldName, entity.L2, "", queryVecNq, sp, common.DefaultTopK)}, // nq != 1
{client.NewANNSearchRequest(common.DefaultFloatVecFieldName, entity.L2, "", queryVecType, sp, common.DefaultTopK)}, // TODO vector type not match
{client.NewANNSearchRequest(common.DefaultFloatVecFieldName, entity.L2, "", queryVecDim, sp, common.DefaultTopK)}, // vector dim not match
{client.NewANNSearchRequest(common.DefaultBinaryVecFieldName, entity.JACCARD, "", queryVecBinary, sp, common.DefaultTopK)}, // not exist vector types
}
for _, invalidSReq := range sReqs {
for idx, invalidSReq := range sReqs {
log.Println(idx)
_, errSearch := mc.HybridSearch(ctx, collName, []string{}, common.DefaultTopK, []string{}, ranker, invalidSReq)
common.CheckErr(t, errSearch, false, "nq should be equal to 1", "vector dimension mismatch",
"failed to get field schema by name", "vector type must be the same")
Expand Down

0 comments on commit 20a8014

Please sign in to comment.