github.com/milvus-io/milvus-sdk-go/v2@v2.4.1/client/results.go (about)

     1  package client
     2  
     3  import (
     4  	"github.com/milvus-io/milvus-sdk-go/v2/entity"
     5  )
     6  
     7  // SearchResult contains the result from Search api of client
     8  // IDs is the auto generated id values for the entities
     9  // Fields contains the data of `outputFieleds` specified or all columns if non
    10  // Scores is actually the distance between the vector current record contains and the search target vector
    11  type SearchResult struct {
    12  	ResultCount  int // the returning entry count
    13  	GroupByValue entity.Column
    14  	IDs          entity.Column // auto generated id, can be mapped to the columns from `Insert` API
    15  	Fields       ResultSet     //[]entity.Column // output field data
    16  	Scores       []float32     // distance to the target vector
    17  	Err          error         // search error if any
    18  }
    19  
    20  // ResultSet is an alias type for column slice.
    21  type ResultSet []entity.Column
    22  
    23  func (rs ResultSet) Len() int {
    24  	if len(rs) == 0 {
    25  		return 0
    26  	}
    27  	return rs[0].Len()
    28  }
    29  
    30  func (rs ResultSet) Slice(start, end int) ResultSet {
    31  	result := make([]entity.Column, 0, len(rs))
    32  	for _, col := range rs {
    33  		result = append(result, col.Slice(start, end))
    34  	}
    35  	return result
    36  }
    37  
    38  // GetColumn returns column with provided field name.
    39  func (rs ResultSet) GetColumn(fieldName string) entity.Column {
    40  	for _, column := range rs {
    41  		if column.Name() == fieldName {
    42  			return column
    43  		}
    44  	}
    45  	return nil
    46  }