A platform for community discussion. Free, open, simple.
FIX: Reduce number of terms injected for host lexeme.
Guo Xiang Tan15e9057ec514
diff --git a/app/services/search_indexer.rb b/app/services/search_indexer.rbindex acd343a00bc..cb60237ab94 100644--- a/app/services/search_indexer.rb+++ b/app/services/search_indexer.rb@@ -65,7 +65,7 @@ class SearchIndexerbreak if count >= 10 # Safeguard here to prevent infinite loop when a term has many dotsterm, _, remaining = lexeme.partition(".")break if remaining.blank?- array << "'#{term}':#{positions} '#{remaining}':#{positions}"+ array << "'#{remaining}':#{positions}"lexeme = remainingendenddiff --git a/spec/services/search_indexer_spec.rb b/spec/services/search_indexer_spec.rbindex e1af96d0f65..f55b183e864 100644--- a/spec/services/search_indexer_spec.rb+++ b/spec/services/search_indexer_spec.rb@@ -108,7 +108,8 @@ describe SearchIndexer doenddescribe '.index' do- let(:post) { Fabricate(:post) }+ let(:topic) { Fabricate(:topic, title: "this is a title that I am testing") }+ let(:post) { Fabricate(:post, topic: topic) }it 'should index posts correctly' doexpect { post }.to change { PostSearchData.count }.by(1)@@ -128,7 +129,7 @@ describe SearchIndexer doendit "should not tokenize urls and duplicate title and href in <a>" do- post = Fabricate(:post, raw: <<~RAW)+ post.update!(raw: <<~RAW)https://meta.discourse.org/some.pngRAW@@ -139,10 +140,13 @@ describe SearchIndexer doexpect(post.post_search_data.raw_data).to eq("https://meta.discourse.org/some.png")++ expect(post.post_search_data.search_data).to eq(+ "'/some.png':12 'discourse.org':11 'meta.discourse.org':11 'meta.discourse.org/some.png':10 'org':11 'test':8A 'titl':4A 'uncategor':9B"+ )endit 'should not tokenize versions' do- post.topic.update!(title: "this is a title that I am testing")post.update!(raw: '123.223')expect(post.post_search_data.search_data).to eq(@@ -174,7 +178,7 @@ describe SearchIndexer do)expect(post.post_search_data.search_data).to eq(- "'/xyz=1':14,17 'abc':13,16 'abc.net':13,16 'abc.net/xyz=1':12,15 'au':10 'awesom':6B 'b':11 'categori':7B 'cnn':9 'cnn.com':9 'com':9,10 'com.au':10 'net':13,16 'stuff':10 'stuff.com.au':10 'test':4A 'topic':5A"+ "'/xyz=1':14,17 'abc.net':13,16 'abc.net/xyz=1':12,15 'au':10 'awesom':6B 'b':11 'categori':7B 'cnn.com':9 'com':9 'com.au':10 'net':13,16 'stuff.com.au':10 'test':4A 'topic':5A")end