lib/europeana/blacklight/document/more_like_this.rb in europeana-blacklight-0.3.2 vs lib/europeana/blacklight/document/more_like_this.rb in europeana-blacklight-0.3.3
- old
+ new
@@ -24,11 +24,11 @@
]
end
def more_like_this_field_terms(*fields)
fields.flatten.map do |field|
- fetch(field, []).compact
+ fetch(field, []).compact[0..9]
end.flatten
end
def more_like_this_field_queries(param = nil)
logic = more_like_this_logic.select do |component|
@@ -40,10 +40,14 @@
end.compact
end
def more_like_this_param_query(param, terms, boost)
return nil unless terms.present?
- or_terms = terms.map do |v|
+
+ string_terms = terms.select { |t| t.is_a?(String) }
+ return nil unless string_terms.present?
+
+ or_terms = string_terms.map do |v|
'"' + Europeana::API::Search.escape(v) + '"'
end.join(' OR ')
"#{param}: (#{or_terms})^#{boost}"
end
end