Commit d26f7de6 authored by Dylan Griffith's avatar Dylan Griffith

Merge branch '277390-global-search-not-finding-result-when-project-search-does' into 'master'

Switch Search Elasticsearch index to use default english stemmer

See merge request gitlab-org/gitlab!48518
parents 1ab894a6 b7298dfb
---
title: Switch Search Elasticsearch index to use english stemmer
merge_request: 48518
author:
type: fixed
......@@ -39,7 +39,7 @@ module Elastic
analyzer: {
default: {
tokenizer: 'standard',
filter: %w(lowercase my_stemmer)
filter: %w(lowercase stemmer)
},
my_ngram_analyzer: {
tokenizer: 'my_ngram_tokenizer',
......@@ -62,10 +62,6 @@ module Elastic
}
},
filter: {
my_stemmer: {
type: 'stemmer',
name: 'light_english'
},
code: {
type: "pattern_capture",
preserve_original: true,
......
......@@ -204,28 +204,11 @@ RSpec.describe Gitlab::Elastic::SearchResults, :elastic, :sidekiq_might_not_need
describe 'issues' do
let(:scope) { 'issues' }
let!(:issue_1) { create(:issue, project: project_1, title: 'Hello world, here I am!', iid: 1) }
let!(:issue_2) { create(:issue, project: project_1, title: 'Issue Two', description: 'Hello world, here I am!', iid: 2) }
let!(:issue_3) { create(:issue, project: project_2, title: 'Issue Three', iid: 2) }
before do
@issue_1 = create(
:issue,
project: project_1,
title: 'Hello world, here I am!',
iid: 1
)
@issue_2 = create(
:issue,
project: project_1,
title: 'Issue Two',
description: 'Hello world, here I am!',
iid: 2
)
@issue_3 = create(
:issue,
project: project_2,
title: 'Issue Three',
iid: 2
)
ensure_elasticsearch_index!
end
......@@ -235,7 +218,7 @@ RSpec.describe Gitlab::Elastic::SearchResults, :elastic, :sidekiq_might_not_need
results = described_class.new(user, 'hello world', limit_project_ids)
issues = results.objects('issues')
expect(issues).to contain_exactly(@issue_1, @issue_2)
expect(issues).to contain_exactly(issue_1, issue_2)
expect(results.issues_count).to eq 2
end
......@@ -250,7 +233,7 @@ RSpec.describe Gitlab::Elastic::SearchResults, :elastic, :sidekiq_might_not_need
results = described_class.new(user, '#2', limit_project_ids, public_and_internal_projects: false)
issues = results.objects('issues')
expect(issues).to contain_exactly(@issue_2)
expect(issues).to contain_exactly(issue_2)
expect(results.issues_count).to eq 1
end
......@@ -258,7 +241,7 @@ RSpec.describe Gitlab::Elastic::SearchResults, :elastic, :sidekiq_might_not_need
results = described_class.new(user, '2', limit_project_ids, public_and_internal_projects: false)
issues = results.objects('issues')
expect(issues).to contain_exactly(@issue_2)
expect(issues).to contain_exactly(issue_2)
expect(results.issues_count).to eq 1
end
......@@ -269,6 +252,18 @@ RSpec.describe Gitlab::Elastic::SearchResults, :elastic, :sidekiq_might_not_need
expect(results.issues_count).to eq 0
end
it 'handles plural words through algorithmic stemming', :aggregate_failures do
issue1 = create(:issue, project: project_1, title: 'remove :title attribute from submit buttons to prevent un-styled tooltips')
issue2 = create(:issue, project: project_1, title: 'smarter submit behavior for buttons groups')
ensure_elasticsearch_index!
results = described_class.new(user, 'button', limit_project_ids)
expect(results.objects('issues')).to contain_exactly(issue1, issue2)
expect(results.issues_count).to eq 2
end
context 'filtering' do
let!(:project) { create(:project, :public) }
let!(:closed_result) { create(:issue, :closed, project: project, title: 'foo closed') }
......@@ -990,7 +985,7 @@ RSpec.describe Gitlab::Elastic::SearchResults, :elastic, :sidekiq_might_not_need
commits = results.objects('commits')
expect(commits.first.message.downcase).to include("add")
expect(results.commits_count).to eq 24
expect(results.commits_count).to eq 21
end
it 'finds commits from public projects only' do
......@@ -1000,10 +995,10 @@ RSpec.describe Gitlab::Elastic::SearchResults, :elastic, :sidekiq_might_not_need
ensure_elasticsearch_index!
results = described_class.new(user, 'add', [project_1.id])
expect(results.commits_count).to eq 24
expect(results.commits_count).to eq 21
results = described_class.new(user, 'add', [project_1.id, project_2.id])
expect(results.commits_count).to eq 48
expect(results.commits_count).to eq 42
end
it 'returns zero when commits are not found' do
......
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