1
我執行與太陽黑子全文檢索,我在其中存儲的文本字段,以獲得突出成績的片段。太陽黑子軌道,突出打擊文本被截斷,只返回一個包含匹配
型號代碼:
searchable do
text :name, :stored => true, :boost => 5.0
text :body, :stored => true, :boost => 3.0
# ... some other non-text fields
end
控制器代碼:
@search = Model.search do
fulltext searchtext, highlight: true # searchtext comes from params
# ... some other fields
end
渲染
@search.hits.each do |hit|
hit.highlights(:name).each do |h|
result = h.format { |word| "<result>#{word}</result>" }
# output the result
end
hit.highlights(:body).each do |h|
result = h.format { |word| "<result>#{word}</result>" }
# output the result
end
end
一切精美的作品,只是當我渲染強調命中,我只有一次實際文本的片段。
所以,與其讓短語(這可能會很長),我只得到它的一個片段。我一直試圖將:fragment_size放在搜索定義(控制器)中,但無濟於事。
如何輸出FULL任何建議(:名稱或:身體),而不是隻是一個亮點吧片段 - >打?
在此先感謝。
缺乏答案,我接受我自己的原因它的工作原理。任何其他更好的答案都會得到「打勾」 –