Skip to content

Commit

Permalink
extract common to_tsvector-string
Browse files Browse the repository at this point in the history
  • Loading branch information
kronn authored and tenderlove committed Nov 30, 2010
1 parent b845140 commit a52612f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/texticle/full_text_index.rb
Expand Up @@ -40,11 +40,12 @@ def to_s
vectors = [] vectors = []
@index_columns.sort_by { |k,v| k }.each do |weight, columns| @index_columns.sort_by { |k,v| k }.each do |weight, columns|
c = columns.map { |x| "coalesce(\"#{@model_class.table_name}\".\"#{x}\", '')" } c = columns.map { |x| "coalesce(\"#{@model_class.table_name}\".\"#{x}\", '')" }
ts_vector = "to_tsvector('#{@dictionary}', #{c.join(" || ' ' || ")})"

if weight == 'none' if weight == 'none'
vectors << "to_tsvector('#{@dictionary}', #{c.join(" || ' ' || ")})" vectors << ts_vector
else else
vectors << vectors << "setweight(#{ts_vector}, '#{weight}')"
"setweight(to_tsvector('#{@dictionary}', #{c.join(" || ' ' || ")}), '#{weight}')"
end end
end end
@string = vectors.join(" || ' ' || ") @string = vectors.join(" || ' ' || ")
Expand Down

0 comments on commit a52612f

Please sign in to comment.