search jobs: support diff, commit and path search#60883
Conversation
This addds support for diff, commit and path results types to Search Jobs. Additionally we now allow multiple search types per search. For example, a search job for the query "secret" will now return path and content matches by default. Before we just returned content matches. I also paid attention to improving the error messages, which relates to feedback we received recently. Notes: - For interactive search, the default types are path, file and repo. For search jobs, the default is path and file, because we don't support repo search yet. Test plan: - new and updated unit tests
e0e4e3f to
69cc104
Compare
jtibshirani
left a comment
There was a problem hiding this comment.
This looks good to me, I left some small comments/ questions as I learn how this works more deeply.
| // This is OK for the EAP but we should remove the limitation soon. | ||
| if !strings.Contains(q, "type:file") { | ||
| q = "type:file " + q | ||
| if strings.Contains(q, "patterntype:structural") { |
There was a problem hiding this comment.
I think we should do a case-insensitive comparison, since patternType:structural is common and valid as well.
There was a problem hiding this comment.
patterntype is hard coded in the client, but I agree, we shouldn't rely on it, especially if customers integrate with the API directly.
|
|
||
| if len(inputs.Plan) != 1 { | ||
| return Exhaustive{}, errors.Errorf("expected a simple expression (no and/or/etc). Got multiple jobs to run %v", inputs.Plan) | ||
| return Exhaustive{}, errors.Errorf("Invalid query: Search Jobs only supports simple expressions. Use AND/OR for patterns but not for filters. Consider splitting into multiple subqueries and creating separate search jobs for each.") |
There was a problem hiding this comment.
Instead of saying "Use AND/OR for patterns but not for filters", maybe we could say "Search Jobs does not support using AND/ OR with filters", and give an example like file:.go or file:.rs? As a user I'd have some trouble understanding the current error.
Yes |
It is currently possible to create search jobs based on `select:` queries although we don't support them. This adds a check to fail validation. ## Test plan - updated unit test
This adds support for diff, commit and path results types to Search Jobs. We also improve the error messages to be more helpful.
Here are a couple of examples of search queries which are now supported in addition to content search
author:alice after:"1 year ago" foo type:diffbas type:commitfile:search.go type:pathNotes:
Test plan: