Skip to content

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?

What are the relevant issue numbers?

Closes #3011 (closed)

Edited by Nick Thomas

Merge request reports

Loading