(ctx context.Context)
| 234 | } |
| 235 | |
| 236 | func (q *SearchQuery) checkValid(ctx context.Context) (sq *SearchQuery, err error) { |
| 237 | if q.Sort >= maxSortType || q.Sort < 0 { |
| 238 | return nil, errors.New("invalid sort type") |
| 239 | } |
| 240 | if q.Continue != "" && q.Around.Valid() { |
| 241 | return nil, errors.New("Continue and Around parameters are mutually exclusive") |
| 242 | } |
| 243 | if q.Sort == MapSort && (q.Continue != "" || q.Around.Valid()) { |
| 244 | return nil, errors.New("Continue or Around parameters are not available with MapSort") |
| 245 | } |
| 246 | if q.Constraint != nil && q.Expression != "" { |
| 247 | return nil, errors.New("Constraint and Expression are mutually exclusive in a search query") |
| 248 | } |
| 249 | if q.Constraint != nil { |
| 250 | return sq, q.Constraint.checkValid() |
| 251 | } |
| 252 | expr := q.Expression |
| 253 | sq, err = parseExpression(ctx, expr) |
| 254 | if err != nil { |
| 255 | return nil, fmt.Errorf("Error parsing search expression %q: %v", expr, err) |
| 256 | } |
| 257 | if err := sq.Constraint.checkValid(); err != nil { |
| 258 | return nil, fmt.Errorf("Internal error: parseExpression(%q) returned invalid constraint: %v", expr, err) |
| 259 | } |
| 260 | return sq, nil |
| 261 | } |
| 262 | |
| 263 | // SearchResult is the result of the Search method for a given SearchQuery. |
| 264 | type SearchResult struct { |
nothing calls this directly
no test coverage detected