Commit e7da9057 authored by charlie ablett's avatar charlie ablett

Merge branch '213265-fix-search-for-complex-queries' into 'master'

Update index_options to fix advanced search queries

Closes #213265

See merge request gitlab-org/gitlab!28712
parents ee9b7754 4d578aa2
---
title: Update index_options to fix advanced search queries
merge_request: 28712
author:
type: fixed
......@@ -117,7 +117,7 @@ module Elastic
indexes :iid, type: :integer
indexes :title, type: :text,
index_options: 'docs'
index_options: 'positions'
indexes :description, type: :text,
index_options: 'positions'
indexes :state, type: :text
......@@ -163,11 +163,11 @@ module Elastic
### PROJECTS
indexes :name, type: :text,
index_options: 'docs'
index_options: 'positions'
indexes :path, type: :text,
index_options: 'docs'
index_options: 'positions'
indexes :name_with_namespace, type: :text,
index_options: 'docs',
index_options: 'positions',
analyzer: :my_ngram_analyzer
indexes :path_with_namespace, type: :text,
index_options: 'positions'
......@@ -185,7 +185,7 @@ module Elastic
### SNIPPETS
indexes :file_name, type: :text,
index_options: 'docs'
index_options: 'positions'
indexes :content, type: :text,
index_options: 'positions'
......@@ -227,14 +227,14 @@ module Elastic
normalizer: :sha_normalizer
indexes :author do
indexes :name, type: :text, index_options: 'docs'
indexes :email, type: :text, index_options: 'docs'
indexes :name, type: :text, index_options: 'positions'
indexes :email, type: :text, index_options: 'positions'
indexes :time, type: :date, format: :basic_date_time_no_millis
end
indexes :committer do
indexes :name, type: :text, index_options: 'docs'
indexes :email, type: :text, index_options: 'docs'
indexes :name, type: :text, index_options: 'positions'
indexes :email, type: :text, index_options: 'positions'
indexes :time, type: :date, format: :basic_date_time_no_millis
end
......
......@@ -45,5 +45,53 @@ RSpec.shared_examples 'EE search service shared examples' do |normal_results, el
is_expected.to be_a(normal_results)
end
context 'advanced syntax queries for all scopes', :elastic, :sidekiq_inline do
queries = [
'"display bug"',
'bug -display',
'bug display | sound',
'bug | (display +sound)',
'bug find_by_*',
'argument \-last'
]
scopes = if elasticsearch_results == ::Gitlab::Elastic::SnippetSearchResults
%w[
snippet_titles
snippet_blobs
]
else
%w[
merge_requests
notes
commits
blobs
projects
issues
wiki_blobs
milestones
]
end
queries.each do |query|
scopes.each do |scope|
context "with query #{query} and scope #{scope}" do
let(:params) { { search: query, scope: scope } }
it "allows advanced query" do
allow(Gitlab::CurrentSettings)
.to receive(:search_using_elasticsearch?)
.and_return(true)
ensure_elasticsearch_index!
results = subject
expect(results.objects(scope)).to be_kind_of(Enumerable)
end
end
end
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment