Fixes #3070 - KB search bar doesn't find indexed attachments

This commit is contained in:
Mantas 2020-06-07 23:23:02 +03:00 committed by Thorsten Eckel
parent 9ef0a368c0
commit 27b3fb4546
2 changed files with 33 additions and 1 deletions

View file

@ -165,7 +165,7 @@ class SearchKnowledgeBaseBackend
if @params.fetch(:highlight_enabled, true) if @params.fetch(:highlight_enabled, true)
output[:highlight_fields_by_indexes] = { output[:highlight_fields_by_indexes] = {
'KnowledgeBase::Answer::Translation': %w[title content.body], 'KnowledgeBase::Answer::Translation': %w[title content.body attachment.content],
'KnowledgeBase::Category::Translation': %w[title], 'KnowledgeBase::Category::Translation': %w[title],
'KnowledgeBase::Translation': %w[title] 'KnowledgeBase::Translation': %w[title]
} }

View file

@ -0,0 +1,32 @@
require 'rails_helper'
RSpec.describe SearchKnowledgeBaseBackend, searchindex: true do
include_context 'basic Knowledge Base'
before do
configure_elasticsearch(required: true, rebuild: true) do
published_answer
end
end
describe '#search' do
let(:instance) { described_class.new options }
let(:user) { create(:admin) }
context 'when highlight enabled' do
let(:options) do
{
knowledge_base: knowledge_base,
locale: primary_locale,
scope: nil,
highlight_enabled: true
}
end
# https://github.com/zammad/zammad/issues/3070
it 'lists item with an attachment' do
expect(instance.search('Hello World', user: user)).to be_present
end
end
end
end