diff --git a/ee/lib/elastic/latest/wiki_class_proxy.rb b/ee/lib/elastic/latest/wiki_class_proxy.rb
index 3cf55855cbc9ce34382f4edc9f82523db32ecb49..41db8d59229290cbc1ef33f781059199edfeb214 100644
--- a/ee/lib/elastic/latest/wiki_class_proxy.rb
+++ b/ee/lib/elastic/latest/wiki_class_proxy.rb
@@ -27,7 +27,7 @@ def elastic_search(
                               per
                             end
 
-        res = search(query_hash, options.slice(:count_only))
+        res = search(query_hash, options)
         { type.pluralize.to_sym => { results: res.results, total_count: res.size } }
       end
 
diff --git a/ee/lib/gitlab/elastic/group_search_results.rb b/ee/lib/gitlab/elastic/group_search_results.rb
index dde4760660c98ad3b95475152fe82e7006f14928..e84036f6f0db2bf38c5efeefcc81337b7959df03 100644
--- a/ee/lib/gitlab/elastic/group_search_results.rb
+++ b/ee/lib/gitlab/elastic/group_search_results.rb
@@ -27,7 +27,7 @@ def base_options
 
       override :scope_options
       def scope_options(scope)
-        # User uses group_id for namespace_yquery
+        # User uses group_id for namespace_query
         case scope
         when :users
           super.except(:group_ids) # User uses group_id for namespace_query
diff --git a/ee/spec/services/search/group_service_spec.rb b/ee/spec/services/search/group_service_spec.rb
index ceb95eb63dc5a56362313975827beb7ccbabfc4f..d378942f967444edf91420a64fe273a198cd5b19 100644
--- a/ee/spec/services/search/group_service_spec.rb
+++ b/ee/spec/services/search/group_service_spec.rb
@@ -291,6 +291,11 @@
       let(:scope) { 'wiki_blobs' }
       let(:search) { 'term' }
 
+      it 'adds correct routing field in the elasticsearch request' do
+        described_class.new(nil, search_level, search: search).execute.objects(scope)
+        assert_routing_field("n_#{search_level.root_ancestor.id}")
+      end
+
       context 'for project wikis' do
         let_it_be_with_reload(:project) { create(:project, :wiki_repo, :in_group) }
 
diff --git a/ee/spec/services/search/project_service_spec.rb b/ee/spec/services/search/project_service_spec.rb
index 39b31f1e2de6afaceb40d9811d52dbcfb986253a..eecd1fc53d60d63d9d49f0d62b204682d0ababe4 100644
--- a/ee/spec/services/search/project_service_spec.rb
+++ b/ee/spec/services/search/project_service_spec.rb
@@ -215,6 +215,7 @@
     include_context 'ProjectPolicyTable context'
 
     let_it_be(:group) { create(:group) }
+    let_it_be(:public_project) { create(:project, :wiki_repo, :public) }
     let_it_be_with_reload(:project) { create(:project, namespace: group) }
     let_it_be_with_reload(:project2) { create(:project) }
 
@@ -341,6 +342,12 @@
       with_them do
         it_behaves_like 'search respects visibility'
       end
+
+      it 'adds correct routing field in the elasticsearch request' do
+        public_project.wiki.create_page('test.md', "# term")
+        described_class.new(nil, public_project, search: search).execute.objects(scope)
+        assert_routing_field("n_#{public_project.root_ancestor.id}")
+      end
     end
 
     context 'milestone' do
diff --git a/ee/spec/support/helpers/elasticsearch_helpers.rb b/ee/spec/support/helpers/elasticsearch_helpers.rb
index 4769428645a49110b2c69711bb2dd966be4d6739..812327a6c513f9cb466d01027a17ce4fb87c5cf2 100644
--- a/ee/spec/support/helpers/elasticsearch_helpers.rb
+++ b/ee/spec/support/helpers/elasticsearch_helpers.rb
@@ -25,6 +25,13 @@ def assert_named_queries(*expected_names, without: [])
     expect(a_named_query).to have_been_made.at_least_once, message
   end
 
+  def assert_routing_field(value)
+    es_host = Gitlab::CurrentSettings.elasticsearch_url.first
+    search_uri = %r{#{es_host}/[\w-]+/_search}
+
+    expect(a_request(:post, search_uri).with(query: hash_including({ 'routing' => value }))).to have_been_made
+  end
+
   def ensure_elasticsearch_index!
     # Ensure that any enqueued updates are processed
     Elastic::ProcessBookkeepingService.new.execute