Commit 8bc1a942 authored by Changzheng Liu's avatar Changzheng Liu Committed by Peter Leitzen

Add project type for global search from ES

parent 67a61557
---
title: Make sure type is set properly in Elasticsearch query when doing global search
merge_request: 22821
author:
type: fixed
......@@ -8,7 +8,7 @@ module Elastic
query_hash = basic_query_hash(options[:in], query)
filters = []
filters = [{ terms: { type: [es_type] } }]
if options[:namespace_id]
filters << {
......
......@@ -94,6 +94,24 @@ describe Project, :elastic do
end
end
# This test is added to address the issues described in
context 'when projects and snippets co-exist', issue: 'https://gitlab.com/gitlab-org/gitlab/issues/36340' do
before do
create :project
create :snippet, :public
end
context 'when searching with a wildcard' do
it 'only returns projects', :sidekiq_inline do
Gitlab::Elastic::Helper.refresh_index
response = described_class.elastic_search('*')
expect(response.total_count).to eq(1)
expect(response.results.first['_source']['type']).to eq(Project.es_type)
end
end
end
it "finds projects" do
project_ids = []
......
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