Fixes #3598 - Search results missing for users with two names within lastname.

This commit is contained in:
Rolf Schmidt 2021-07-06 17:36:27 +00:00 committed by Thorsten Eckel
parent 6cbe99704f
commit 1bf188d7ac
2 changed files with 17 additions and 1 deletions

View file

@ -6,6 +6,7 @@ class User
def search_index_attribute_lookup(include_references: true)
attributes = super
attributes['fullname'] = fullname
attributes.delete('password')
if include_references

View file

@ -27,7 +27,7 @@ RSpec.describe SearchIndexBackend, searchindex: true do
let(:record) { create :ticket }
before do
described_class.add(record_type, record)
record.search_index_update_backend
described_class.refresh
end
@ -37,6 +37,21 @@ RSpec.describe SearchIndexBackend, searchindex: true do
end
end
context 'when search for user firstname + double lastname' do
let(:record_type) { 'User'.freeze }
let(:record) { create :user, login: 'a', email: 'a@a.de', firstname: 'AnFirst', lastname: 'ASplit Lastname' }
before do
record.search_index_update_backend
described_class.refresh
end
it 'finds user record' do
result = described_class.search('AnFirst ASplit Lastname', record_type, sort_by: ['updated_at'], order_by: ['desc'])
expect(result).to eq([{ id: record.id.to_s, type: record_type }])
end
end
context 'for query with no results' do
subject(:search) { described_class.search(query, index, limit: 3000) }