mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 02:11:08 -06:00
FIX: in:title
search should only search through topic first posts.
This commit is contained in:
parent
84de643c04
commit
af87911178
@ -847,6 +847,7 @@ class Search
|
||||
# C is for tags
|
||||
# D is for cooked
|
||||
weights = @in_title ? 'A' : (SiteSetting.tagging_enabled ? 'ABCD' : 'ABD')
|
||||
posts = posts.where(post_number: 1) if @in_title
|
||||
posts = posts.where("post_search_data.search_data @@ #{ts_query(weight_filter: weights)}")
|
||||
exact_terms = @term.scan(Regexp.new(PHRASE_MATCH_REGEXP_PATTERN)).flatten
|
||||
|
||||
|
@ -1513,19 +1513,14 @@ describe Search do
|
||||
context 'in:title' do
|
||||
it 'allows for search in title' do
|
||||
topic = Fabricate(:topic, title: 'I am testing a title search')
|
||||
_post = Fabricate(:post, topic: topic, raw: 'this is the first post')
|
||||
post2 = Fabricate(:post, topic: topic, raw: 'this is the second post', post_number: 2)
|
||||
post = Fabricate(:post, topic: topic, raw: 'this is the first post', post_number: 1)
|
||||
|
||||
results = Search.execute('title in:title')
|
||||
expect(results.posts.length).to eq(1)
|
||||
|
||||
results = Search.execute('title t')
|
||||
expect(results.posts.length).to eq(1)
|
||||
expect(results.posts.map(&:id)).to eq([post.id])
|
||||
|
||||
results = Search.execute('first in:title')
|
||||
expect(results.posts.length).to eq(0)
|
||||
|
||||
results = Search.execute('first t')
|
||||
expect(results.posts.length).to eq(0)
|
||||
expect(results.posts).to eq([])
|
||||
end
|
||||
|
||||
it 'works irrespective of the order' do
|
||||
|
Loading…
Reference in New Issue
Block a user