mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 08:03:36 +08:00
fc311dbe3b
On very large forums searching posts can be slow, so this commit introduces the ability to try and search only the most recent posts first, and then going for a larger breadth search if there aren't enough results. Enable `search_prefer_recent_posts` and you can customize how many recent posts to filter with `search_recent_posts_size`
31 lines
862 B
Ruby
31 lines
862 B
Ruby
require 'rails_helper'
|
|
|
|
describe SearchObserver do
|
|
|
|
it 'correctly indexes chinese' do
|
|
SiteSetting.default_locale = 'zh_CN'
|
|
data = "你好世界"
|
|
expect(data.split(" ").length).to eq(1)
|
|
|
|
SearchObserver.update_posts_index(99, "你好世界", "", nil)
|
|
|
|
raw_data = PostSearchData.where(post_id: 99).pluck(:raw_data)[0]
|
|
expect(raw_data.split(' ').length).to eq(2)
|
|
end
|
|
|
|
it 'correctly indexes a post' do
|
|
data = "<a>This</a> is a test"
|
|
|
|
SearchObserver.update_posts_index(99, data, "", nil)
|
|
|
|
raw_data, locale = PostSearchData.where(post_id: 99).pluck(:raw_data, :locale)[0]
|
|
expect(raw_data).to eq("This is a test")
|
|
expect(locale).to eq("en")
|
|
|
|
SearchObserver.update_posts_index(99, "tester", "", nil)
|
|
|
|
raw_data = PostSearchData.where(post_id: 99).pluck(:raw_data)[0]
|
|
expect(raw_data).to eq("tester")
|
|
end
|
|
end
|