Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix hybrid search case and response check #706

Merged
merged 2 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 2 additions & 2 deletions test/testcases/search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1313,7 +1313,7 @@ func TestRangeSearchScannL2(t *testing.T) {
sp.AddRangeFilter(20)
_, errRange := mc.Search(ctx, collName, []string{}, "", []string{"*"}, queryVec, common.DefaultFloatVecFieldName,
entity.L2, common.DefaultTopK, sp)
common.CheckErr(t, errRange, false, "range_filter must be less than radius for L2/HAMMING/JACCARD")
common.CheckErr(t, errRange, false, "must be less than radius")
}

// test range search with scann index and IP COSINE metric type
Expand Down Expand Up @@ -1372,7 +1372,7 @@ func TestRangeSearchScannIPCosine(t *testing.T) {
sp.AddRangeFilter(10)
_, errRange := mc.Search(ctx, collName, []string{}, "", []string{"*"}, queryVec, common.DefaultFloatVecFieldName,
metricType, common.DefaultTopK, sp)
common.CheckErr(t, errRange, false, "range_filter must be greater than radius for IP/COSINE")
common.CheckErr(t, errRange, false, "must be greater than radius")
}
}

Expand Down
Loading