mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-01-07 19:31:51 +08:00
fix: [CHERRY-PICK] [restful v2] add hybrid_search (#31395)
search issue: #30688 2.4 pr: #31344 Signed-off-by: PowderLi <min.li@zilliz.com>
This commit is contained in:
parent
b63c29b4fa
commit
ee56ae7299
@ -35,6 +35,7 @@ const (
|
||||
UpsertAction = "upsert"
|
||||
SearchAction = "search"
|
||||
AdvancedSearchAction = "advanced_search"
|
||||
HybridSearchAction = "hybrid_search"
|
||||
|
||||
UpdatePasswordAction = "update_password"
|
||||
GrantRoleAction = "grant_role"
|
||||
|
||||
@ -89,6 +89,11 @@ func (h *HandlersV2) RegisterRoutesToV2(router gin.IRouter) {
|
||||
Limit: 100,
|
||||
}
|
||||
}, wrapperTraceLog(h.wrapperCheckDatabase(h.advancedSearch)))))
|
||||
router.POST(EntityCategory+HybridSearchAction, timeoutMiddleware(wrapperPost(func() any {
|
||||
return &HybridSearchReq{
|
||||
Limit: 100,
|
||||
}
|
||||
}, wrapperTraceLog(h.wrapperCheckDatabase(h.advancedSearch)))))
|
||||
|
||||
router.POST(PartitionCategory+ListAction, timeoutMiddleware(wrapperPost(func() any { return &CollectionNameReq{} }, wrapperTraceLog(h.wrapperCheckDatabase(h.listPartitions)))))
|
||||
router.POST(PartitionCategory+HasAction, timeoutMiddleware(wrapperPost(func() any { return &PartitionReq{} }, wrapperTraceLog(h.wrapperCheckDatabase(h.hasPartitions)))))
|
||||
|
||||
@ -1135,13 +1135,13 @@ func TestSearchV2(t *testing.T) {
|
||||
Schema: generateCollectionSchema(schemapb.DataType_Int64),
|
||||
ShardsNum: ShardNumDefault,
|
||||
Status: &StatusSuccess,
|
||||
}, nil).Times(9)
|
||||
}, nil).Times(10)
|
||||
mp.EXPECT().Search(mock.Anything, mock.Anything).Return(&milvuspb.SearchResults{Status: commonSuccessStatus, Results: &schemapb.SearchResultData{TopK: int64(0)}}, nil).Times(3)
|
||||
mp.EXPECT().Search(mock.Anything, mock.Anything).Return(&milvuspb.SearchResults{Status: &commonpb.Status{
|
||||
ErrorCode: 1700, // ErrFieldNotFound
|
||||
Reason: "groupBy field not found in schema: field not found[field=test]",
|
||||
}}, nil).Once()
|
||||
mp.EXPECT().HybridSearch(mock.Anything, mock.Anything).Return(&milvuspb.SearchResults{Status: commonSuccessStatus, Results: &schemapb.SearchResultData{TopK: int64(0)}}, nil).Twice()
|
||||
mp.EXPECT().HybridSearch(mock.Anything, mock.Anything).Return(&milvuspb.SearchResults{Status: commonSuccessStatus, Results: &schemapb.SearchResultData{TopK: int64(0)}}, nil).Times(3)
|
||||
collSchema := generateCollectionSchema(schemapb.DataType_Int64)
|
||||
binaryVectorField := generateVectorFieldSchema(schemapb.DataType_BinaryVector)
|
||||
binaryVectorField.Name = "binaryVector"
|
||||
@ -1195,6 +1195,10 @@ func TestSearchV2(t *testing.T) {
|
||||
path: AdvancedSearchAction,
|
||||
requestBody: []byte(`{"collectionName": "hello_milvus", "search": [{"data": [[0.1, 0.2]], "annsField": "book_intro", "metricType": "L2", "limit": 3}, {"data": [[0.1, 0.2]], "annsField": "book_intro", "metricType": "L2", "limit": 3}], "rerank": {"strategy": "weighted", "params": {"weights": [0.9, 0.8]}}}`),
|
||||
})
|
||||
queryTestCases = append(queryTestCases, requestBodyTestCase{
|
||||
path: HybridSearchAction,
|
||||
requestBody: []byte(`{"collectionName": "hello_milvus", "search": [{"data": [[0.1, 0.2]], "annsField": "book_intro", "metricType": "L2", "limit": 3}, {"data": [[0.1, 0.2]], "annsField": "book_intro", "metricType": "L2", "limit": 3}], "rerank": {"strategy": "weighted", "params": {"weights": [0.9, 0.8]}}}`),
|
||||
})
|
||||
// annsField
|
||||
queryTestCases = append(queryTestCases, requestBodyTestCase{
|
||||
path: SearchAction,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user