Fix error when search on collection without partitions

Signed-off-by: xige-16 <xi.ge@zilliz.com>
pull/4973/head^2
xige-16 2021-03-15 19:58:52 +08:00 committed by yefu.chen
parent ec8ad89900
commit b92ad3edd6
1 changed files with 12 additions and 7 deletions

View File

@ -4,7 +4,6 @@ import "C"
import (
"context"
"errors"
"regexp"
"strconv"
"strings"
"sync"
@ -250,16 +249,22 @@ func (ss *searchService) search(msg msgstream.TsMsg) error {
var searchPartitionIDs []UniqueID
partitionIDsInQuery := searchMsg.PartitionIDs
if len(partitionIDsInQuery) == 0 {
if len(partitionIDsInCol) == 0 {
return errors.New("can't find any partition in this collection on query node")
}
searchPartitionIDs = partitionIDsInCol
} else {
for _, id := range partitionIDsInCol {
for _, toMatchID := range partitionIDsInQuery {
re := regexp.MustCompile("^" + strconv.FormatInt(toMatchID, 10) + "$")
if re.MatchString(strconv.FormatInt(id, 10)) {
searchPartitionIDs = append(searchPartitionIDs, id)
}
findPartition := false
for _, id := range partitionIDsInQuery {
_, err := ss.replica.getPartitionByID(id)
if err == nil {
searchPartitionIDs = append(searchPartitionIDs, id)
findPartition = true
}
}
if !findPartition {
return errors.New("partition to be searched not exist in query node")
}
}
for _, partitionID := range searchPartitionIDs {