The source project of this merge request has been removed.
Fix advanced search syntax for commits
What does this MR do?
The introduction of advanced search syntax allowed queries like -foo
. These break our repository queries in two distinct ways:
- Blobs would be returned for commit queries, and vice-versa
- Highlighting was assumed to be present for all queries
The first is fixed by adding explicit type terms to the queries:
{ term: { 'commit.type' => 'commit' } }
{ term: { 'blob.type' => 'blob' } }
(The _type
field is, of course, repository
for both document kinds).
A query matched by a negative search will not have any highlighting results, so we also need to make processing that conditional.
Finally, switch commit search to default_operator: :and
so it behaves more like the rest of the application.
Are there points in the code the reviewer needs to double check?
Why was this MR needed?
Fix NoMethodError
exceptions when performing searches with negation
Screenshots (if relevant)
Does this MR meet the acceptance criteria?
-
Changelog entry added, if necessary -
Documentation created/updated -
API support added - Tests
-
Added for this feature/bug -
All builds are passing
-
-
Conform by the merge request performance guides -
Conform by the style guides -
Branch has no merge conflicts with master
(if it does - rebase it please) -
Squashed related commits together
What are the relevant issue numbers?
Closes #3011 (closed)
Edited by Nick Thomas