(eid int64, reqs []*SearchRequest)
| 754 | } |
| 755 | |
| 756 | func (s *SearchService) resolveBatchCollection(eid int64, reqs []*SearchRequest) (string, error) { |
| 757 | if len(reqs) == 0 { |
| 758 | return "", fmt.Errorf("搜索请求不能为空") |
| 759 | } |
| 760 | if len(reqs[0].LibraryIDs) != 1 { |
| 761 | return "", fmt.Errorf("批量搜索仅支持单知识库") |
| 762 | } |
| 763 | |
| 764 | libraryID := reqs[0].LibraryIDs[0] |
| 765 | for i := 1; i < len(reqs); i++ { |
| 766 | if len(reqs[i].LibraryIDs) != 1 || reqs[i].LibraryIDs[0] != libraryID { |
| 767 | return "", fmt.Errorf("批量搜索需要相同的知识库范围") |
| 768 | } |
| 769 | } |
| 770 | |
| 771 | libraries, err := s.batchGetLibrariesByIDs(eid, []int64{libraryID}) |
| 772 | if err != nil { |
| 773 | return "", err |
| 774 | } |
| 775 | library, ok := libraries[libraryID] |
| 776 | if !ok || library == nil { |
| 777 | return "", fmt.Errorf("知识库不存在: %d", libraryID) |
| 778 | } |
| 779 | |
| 780 | return model.GetVectorCollectionName(library.UUID), nil |
| 781 | } |
| 782 | |
| 783 | func (s *SearchService) resolveBatchCollections(eid int64, reqs []*SearchRequest) ([]batchVectorCollection, error) { |
| 784 | if len(reqs) == 0 { |
nothing calls this directly
no test coverage detected