Changeset 324
- Timestamp:
- 05/08/08 01:07:47 (7 months ago)
- Files:
-
- trunk/lib/picolena/templates/app/models/query.rb (modified) (1 diff)
- trunk/lib/picolena/templates/spec/models/query_spec.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/picolena/templates/app/models/query.rb
r263 r324 4 4 def extract_from(raw_query) 5 5 parser.parse(convert_to_english(raw_query)) 6 end 7 8 # Returns terms related to content. Useful for cache highlighting 9 def content_terms(raw_query) 10 Query.extract_from(raw_query).terms(Indexer.index.searcher).select{|term| term.field==:content}.collect{|term| term.text}.uniq 6 11 end 7 12 trunk/lib/picolena/templates/spec/models/query_spec.rb
r307 r324 77 77 Query.extract_from("test").should_not == Query.extract_from("tesTe") 78 78 end 79 80 it "should be able to extract search terms related to :content" do 81 Query.content_terms("plain text").should == %w(plain text) 82 Query.content_terms("plain text extension:pdf").should == %w(plain text) 83 Query.content_terms("plain AND text").should == %w(plain text) 84 Query.content_terms("absorption OR adsorption").should ==%w(absorption adsorption) 85 Query.content_terms("filename:plain_text").should be_empty 86 Globalite.language = :en 87 Query.content_terms("LIKE absorption").include?("adsorption").should be_true 88 end 79 89 end
