• Nick Thomas's avatar
    Elasticsearch fixes for advanced search syntax · 4095e48d
    Nick Thomas authored
    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.
    
    Switching to `default_operator: :and` should be enough to keep this from
    happening.
    4095e48d
search_results.rb 7.06 KB