Changeset 239
- Timestamp:
- 04/24/08 06:53:56 (7 months ago)
- Files:
-
- branches/yet_another_index_structure/lib/picolena/templates/app/models/document.rb (modified) (1 diff)
- branches/yet_another_index_structure/lib/picolena/templates/app/models/indexer.rb (modified) (3 diffs)
- branches/yet_another_index_structure/lib/picolena/templates/app/models/query.rb (modified) (2 diffs)
- branches/yet_another_index_structure/lib/picolena/templates/lang/ui/de.yml (modified) (1 diff)
- branches/yet_another_index_structure/lib/picolena/templates/lang/ui/en.yml (modified) (1 diff)
- branches/yet_another_index_structure/lib/picolena/templates/lang/ui/es.yml (modified) (1 diff)
- branches/yet_another_index_structure/lib/picolena/templates/lang/ui/fr.yml (modified) (1 diff)
- branches/yet_another_index_structure/lib/picolena/templates/spec/models/basic_finder_spec.rb (modified) (1 diff)
- branches/yet_another_index_structure/lib/picolena/templates/spec/models/finder_spec.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/yet_another_index_structure/lib/picolena/templates/app/models/document.rb
r238 r239 72 72 # Useful to know how old a document is, and to which version the cache corresponds. 73 73 def date 74 from_index[: date].sub(/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/,'\1-\2-\3 \4:\5:\6')74 from_index[:modified].sub(/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/,'\1-\2-\3 \4:\5:\6') 75 75 end 76 76 77 77 def mtime 78 from_index[: date].to_i78 from_index[:modified].to_i 79 79 end 80 80 81 81 # Returns language. 82 82 def lang 83 from_index[:lang ]83 from_index[:language] 84 84 end 85 85 branches/yet_another_index_structure/lib/picolena/templates/app/models/indexer.rb
r238 r239 67 67 # Creates it otherwise. 68 68 def writer 69 @@writer ||= Ferret::Index::IndexWriter.new(default_index_ writer_params)69 @@writer ||= Ferret::Index::IndexWriter.new(default_index_params) 70 70 end 71 71 … … 95 95 96 96 def default_index_params 97 {:path => Picolena::IndexSavePath, :analyzer => Picolena::Analyzer }97 {:path => Picolena::IndexSavePath, :analyzer => Picolena::Analyzer, :field_infos => default_field_infos} 98 98 end 99 99 … … 107 107 field_infos.add_field(:modified, :store => :yes, :index => :untokenized) 108 108 field_infos.add_field(:probably_unique_id, :store => :no, :index => :yes) 109 field_infos.add_field(:lang ,:store => :yes, :index => :yes)109 field_infos.add_field(:language, :store => :yes, :index => :yes) 110 110 end 111 end112 113 def default_index_writer_params114 default_index_params.merge :field_infos => default_field_infos115 111 end 116 112 end branches/yet_another_index_structure/lib/picolena/templates/app/models/query.rb
r177 r239 14 14 /\b#{:OR.l}\b/=>'OR', 15 15 /\b#{:NOT.l}\b/=>'NOT', 16 /(#{:filename.l}):/=>'filename:', 16 17 /(#{:filetype.l}):/=>'filetype:', 17 18 /#{:content.l}:/ => 'content:', 18 /#{:date.l}:/ => 'date:', 19 /(#{:modified.l}):/ => 'modified:', 20 /(#{:language.l}):/ => 'language:', 19 21 /\b#{:LIKE.l}\s+(\S+)/=>'\1~' 20 22 } … … 26 28 # Instantiates a QueryParser once, and keeps it in cache. 27 29 def parser 28 @@parser ||= Ferret::QueryParser.new(:fields => [:content, :file , :basename, :filetype, :date], :or_default => false, :analyzer=>Picolena::Analyzer)30 @@parser ||= Ferret::QueryParser.new(:fields => [:content, :filename, :basename, :filetype, :modified], :or_default => false, :analyzer=>Picolena::Analyzer) 29 31 end 30 32 end branches/yet_another_index_structure/lib/picolena/templates/lang/ui/de.yml
r128 r239 20 20 21 21 ## Fields 22 filename: filename|file|datei 22 23 filetype: erweiterung|ext 23 24 content: inhalt 24 date: jahr|zeit 25 modified: jahr|zeit|geÀndert 26 language: lang|sprache branches/yet_another_index_structure/lib/picolena/templates/lang/ui/en.yml
r128 r239 20 20 21 21 ## Fields 22 filename: filename|file 22 23 filetype: filetype|ext 23 24 content: content 24 date: year|date 25 modified: year|date|modified 26 language: lang|language branches/yet_another_index_structure/lib/picolena/templates/lang/ui/es.yml
r128 r239 20 20 21 21 ## Fields 22 filename: filename|file|archivo 22 23 filetype: extensión|ext 23 24 content: contenido 24 date: fecha|año|anho 25 modified: fecha|año|anho|modificado 26 language: lang|idioma branches/yet_another_index_structure/lib/picolena/templates/lang/ui/fr.yml
r128 r239 20 20 21 21 ## Fields 22 filename: filename|file|fichier 22 23 filetype: extension|ext 23 24 content: contenu 24 date: année|date|annee 25 modified: année|date|annee|modifie 26 language: lang|langue branches/yet_another_index_structure/lib/picolena/templates/spec/models/basic_finder_spec.rb
r238 r239 36 36 fields={ 37 37 # description => key 38 :content=>:content, 39 :basename=>:basename, 40 :filename=>:file, 41 :extension => :filetype, 42 :modification_time=>:date 38 :content => :content, 39 :complete_path => :complete_path, 40 :basename => :basename, 41 :filename => :filename, 42 :extension => :filetype, 43 :modification_time => :modified, 44 :probably_unique_id => :probably_unique_id, 45 :language => :language 43 46 } 44 47 branches/yet_another_index_structure/lib/picolena/templates/spec/models/finder_spec.rb
r238 r239 31 31 end 32 32 33 it "should find documents according to their filename when specified with file:query " do34 Finder.new("file :crossed.text").matching_documents.collect{|d| d.content}.should include("txt inside!")33 it "should find documents according to their filename when specified with file:query or filename:query" do 34 Finder.new("filename:crossed.text").matching_documents.collect{|d| d.content}.should include("txt inside!") 35 35 Finder.new("file:crossed.txt").matching_documents.collect{|d| d.content}.should include("text inside!") 36 36 end
