lib/picolena/templates/app/models/query.rb in picolena-0.1.7 vs lib/picolena/templates/app/models/query.rb in picolena-0.1.8
- old
+ new
@@ -2,9 +2,14 @@
class << self
# Returns a Ferret::Query from a raw String query.
def extract_from(raw_query)
parser.parse(convert_to_english(raw_query))
end
+
+ # Returns terms related to content. Useful for cache highlighting
+ def content_terms(raw_query)
+ Query.extract_from(raw_query).terms(Indexer.index.searcher).select{|term| term.field==:content}.collect{|term| term.text}.uniq
+ end
private
# Converts query keywords to english so they can be parsed by Ferret.
def convert_to_english(raw_query)
\ No newline at end of file