mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-01-07 19:31:51 +08:00
Skip unnecessary reduce phase during search (#25166)
Signed-off-by: longjiquan <jiquan.long@zilliz.com>
This commit is contained in:
parent
9b91519c88
commit
8d193a3e56
@ -253,7 +253,7 @@ func (sd *shardDelegator) Search(ctx context.Context, req *querypb.SearchRequest
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.Info("Delegator search done")
|
||||
log.Debug("Delegator search done")
|
||||
|
||||
return results, nil
|
||||
}
|
||||
@ -484,7 +484,7 @@ func (sd *shardDelegator) waitTSafe(ctx context.Context, ts uint64) error {
|
||||
lag := gt.Sub(st)
|
||||
maxLag := paramtable.Get().QueryNodeCfg.MaxTimestampLag.GetAsDuration(time.Second)
|
||||
if lag > maxLag {
|
||||
log.Warn("guarantee and servicable ts larger than MaxLag",
|
||||
log.Warn("guarantee and serviceable ts larger than MaxLag",
|
||||
zap.Time("guaranteeTime", gt),
|
||||
zap.Time("serviceableTime", st),
|
||||
zap.Duration("lag", lag),
|
||||
|
||||
@ -40,6 +40,14 @@ var _ typeutil.ResultWithID = &internalpb.RetrieveResults{}
|
||||
var _ typeutil.ResultWithID = &segcorepb.RetrieveResults{}
|
||||
|
||||
func ReduceSearchResults(ctx context.Context, results []*internalpb.SearchResults, nq int64, topk int64, metricType string) (*internalpb.SearchResults, error) {
|
||||
results = lo.Filter(results, func(result *internalpb.SearchResults, _ int) bool {
|
||||
return result != nil && result.GetSlicedBlob() != nil
|
||||
})
|
||||
|
||||
if len(results) == 1 {
|
||||
return results[0], nil
|
||||
}
|
||||
|
||||
log := log.Ctx(ctx)
|
||||
|
||||
searchResultData, err := DecodeSearchResults(results)
|
||||
|
||||
@ -207,7 +207,9 @@ func (s *JSONExprSuite) TestJSON_InsertWithoutDynamicData() {
|
||||
// search
|
||||
expr = `$meta["A"] > 90`
|
||||
checkFunc := func(result *milvuspb.SearchResults) {
|
||||
s.Equal(0, len(result.Results.FieldsData))
|
||||
for _, f := range result.Results.GetFieldsData() {
|
||||
s.Nil(f)
|
||||
}
|
||||
}
|
||||
s.doSearch(collectionName, []string{common.MetaFieldName}, expr, dim, checkFunc)
|
||||
log.Info("GT expression run successfully")
|
||||
@ -563,7 +565,9 @@ func (s *JSONExprSuite) checkSearch(collectionName, fieldName string, dim int) {
|
||||
|
||||
expr = `exists AAA`
|
||||
checkFunc = func(result *milvuspb.SearchResults) {
|
||||
s.Equal(0, len(result.Results.FieldsData))
|
||||
for _, f := range result.Results.GetFieldsData() {
|
||||
s.Nil(f)
|
||||
}
|
||||
}
|
||||
s.doSearch(collectionName, []string{fieldName}, expr, dim, checkFunc)
|
||||
log.Info("EXISTS expression run successfully")
|
||||
@ -610,7 +614,9 @@ func (s *JSONExprSuite) checkSearch(collectionName, fieldName string, dim int) {
|
||||
|
||||
expr = `A like "10"`
|
||||
checkFunc = func(result *milvuspb.SearchResults) {
|
||||
s.Equal(0, len(result.Results.FieldsData))
|
||||
for _, f := range result.Results.GetFieldsData() {
|
||||
s.Nil(f)
|
||||
}
|
||||
}
|
||||
s.doSearch(collectionName, []string{fieldName}, expr, dim, checkFunc)
|
||||
log.Info("like expression run successfully")
|
||||
@ -627,14 +633,18 @@ func (s *JSONExprSuite) checkSearch(collectionName, fieldName string, dim int) {
|
||||
|
||||
expr = `str1 like 'abc"def-%'`
|
||||
checkFunc = func(result *milvuspb.SearchResults) {
|
||||
s.Equal(0, len(result.Results.FieldsData))
|
||||
for _, f := range result.Results.GetFieldsData() {
|
||||
s.Nil(f)
|
||||
}
|
||||
}
|
||||
s.doSearch(collectionName, []string{fieldName}, expr, dim, checkFunc)
|
||||
log.Info("like expression run successfully")
|
||||
|
||||
expr = `str2 like 'abc\"def-%'`
|
||||
checkFunc = func(result *milvuspb.SearchResults) {
|
||||
s.Equal(0, len(result.Results.FieldsData))
|
||||
for _, f := range result.Results.GetFieldsData() {
|
||||
s.Nil(f)
|
||||
}
|
||||
}
|
||||
s.doSearch(collectionName, []string{fieldName}, expr, dim, checkFunc)
|
||||
log.Info("like expression run successfully")
|
||||
@ -651,7 +661,9 @@ func (s *JSONExprSuite) checkSearch(collectionName, fieldName string, dim int) {
|
||||
|
||||
expr = `A in []`
|
||||
checkFunc = func(result *milvuspb.SearchResults) {
|
||||
s.Equal(0, len(result.Results.FieldsData))
|
||||
for _, f := range result.Results.GetFieldsData() {
|
||||
s.Nil(f)
|
||||
}
|
||||
}
|
||||
s.doSearch(collectionName, []string{fieldName}, expr, dim, checkFunc)
|
||||
log.Info("term empty expression run successfully")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user