Skip to content

Negation queries with advanced search syntax break global code, commit and wiki search

Zendesk: https://gitlab.zendesk.com/agent/tickets/80192

With a few customers recently we've noticed that ES < 5.4 does not work at all - no results are returned even with basic keyword search. However, 5.4+ seem to work for basic search. This customer reports the following error when using advanced search with 5.5, such as Smith -code.

Completed 500 Internal Server Error in 204ms (ActiveRecord: 0.7ms | Elasticsearch: 97.5ms)

ActionView::Template::Error (undefined method `[]' for nil:NilClass):
    89:           = link_to search_filter_path(scope: 'commits') do
    90:             Commits
    91:             %span.badge
    92:               = @search_results.commits_count
    93:         %li{ class: active_when(@scope == 'wiki_blobs') }
    94:           = link_to search_filter_path(scope: 'wiki_blobs') do
    95:             Wiki
  app/models/concerns/elastic/repositories_search.rb:53:in `block in find_commits_by_message_with_elastic'
  app/models/concerns/elastic/repositories_search.rb:53:in `map'
  app/models/concerns/elastic/repositories_search.rb:53:in `find_commits_by_message_with_elastic'
  lib/gitlab/elastic/search_results.rb:180:in `commits'
  lib/gitlab/elastic/search_results.rb:51:in `commits_count'
  app/views/search/_category.html.haml:92:in `block in _app_views_search__category_html_haml___2080153321503535010_70107465357880'
  app/views/search/_category.html.haml:89:in `_app_views_search__category_html_haml___2080153321503535010_70107465357880'
  app/views/search/show.html.haml:8:in `_app_views_search_show_html_haml__2624193491189907620_70107603476200'
  lib/gitlab/i18n.rb:45:in `with_locale'
  lib/gitlab/i18n.rb:51:in `with_user_locale'
  app/controllers/application_controller.rb:298:in `set_locale'
  lib/gitlab/performance_bar/peek_performance_bar_with_rack_body.rb:16:in `call'
  lib/gitlab/middleware/multipart.rb:93:in `call'
  lib/gitlab/request_profiler/middleware.rb:14:in `call'
  lib/gitlab/middleware/go.rb:16:in `call'
  lib/gitlab/etag_caching/middleware.rb:11:in `call'
  lib/gitlab/middleware/readonly_geo.rb:30:in `call'
  lib/gitlab/request_context.rb:18:in `call'
  lib/gitlab/metrics/connection_rack_middleware.rb:31:in `call'

@nick.thomas Do you have any ideas here?

Edited by Nick Thomas