Hi! I''ve got a problem with the search_generator. I do exactly like the README file and it is not working :/ When I want to do a search, I go to http://website/search/mykeyword and the errors returned : NoMethodError in Search#index undefined method `each'' for #<MockContents:0xb783d52c> |app/controllers/search_controller.rb:18:in `search'' app/controllers/search_controller.rb:7:in `index'' script/server:50| The line 18 corresponds to : simple_index = Search::Simple::Searcher.load(empty_contents,"#{File.dirname(__FILE__)}/../../db/search_cache") The parameters seems to be ok because I have: *Parameters*: {"search_terms"=>"mykeyword", "count"=>"-1"} I don''t understand what''s going on in this script :/ Thanks.
Hi, I left out a very important item in the README. You must first index your data by running the script/indexer script. This will create the search_cache file and you shouldn''t get that error anymore. I''ll release a new version of the the gem today with some updates. enjoy, -jeremy On Sun, Apr 24, 2005 at 12:13:41PM +0200, Bruno Celeste wrote:> Hi! > > I''ve got a problem with the search_generator. I do exactly like the > README file and it is not working :/ > When I want to do a search, I go to http://website/search/mykeyword > > and the errors returned : > > > NoMethodError in Search#index > > undefined method `each'' for #<MockContents:0xb783d52c> > > |app/controllers/search_controller.rb:18:in `search'' > app/controllers/search_controller.rb:7:in `index'' > script/server:50| > > > The line 18 corresponds to : > > simple_index = Search::Simple::Searcher.load(empty_contents,"#{File.dirname(__FILE__)}/../../db/search_cache") > > > The parameters seems to be ok because I have: > > *Parameters*: {"search_terms"=>"mykeyword", "count"=>"-1"} > > I don''t understand what''s going on in this script :/ > > Thanks. > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-- ======================================================================= Jeremy Hinegardner jeremy-eg9WJcVQRd1EMKyauTCisw@public.gmane.org
I am currently using a SQL search in my project but am considering moving over to your generator (since 500 character queries aren''t exactly my thing). What I was wondering is how does indexing work? Is it something that I need to make a cron entry for and run periodically? Is it something that I can task whenever I make a data change that needs it (meaning is a slight update to the data much less costly or is every index rebuild the same)? Is it highly CPU intensive and somethiing I should be careful about? Sorry for the barrage of questions. Perhaps you can shed some light. Thanks, Brian On 4/24/05, Jeremy Hinegardner <jeremy-eg9WJcVQRd1EMKyauTCisw@public.gmane.org> wrote:> Hi, > > I left out a very important item in the README. You must first index > your data by running the script/indexer script. This will create the > search_cache file and you shouldn''t get that error anymore. > > I''ll release a new version of the the gem today with some updates. > > enjoy, > > -jeremy > > On Sun, Apr 24, 2005 at 12:13:41PM +0200, Bruno Celeste wrote: > > Hi! > > > > I''ve got a problem with the search_generator. I do exactly like the > > README file and it is not working :/ > > When I want to do a search, I go to http://website/search/mykeyword > > > > and the errors returned : > > > > > > NoMethodError in Search#index > > > > undefined method `each'' for #<MockContents:0xb783d52c> > > > > |app/controllers/search_controller.rb:18:in `search'' > > app/controllers/search_controller.rb:7:in `index'' > > script/server:50| > > > > > > The line 18 corresponds to : > > > > simple_index = Search::Simple::Searcher.load(empty_contents,"#{File.dirname(__FILE__)}/../../db/search_cache") > > > > > > The parameters seems to be ok because I have: > > > > *Parameters*: {"search_terms"=>"mykeyword", "count"=>"-1"} > > > > I don''t understand what''s going on in this script :/ > > > > Thanks. > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > -- > =======================================================================> Jeremy Hinegardner jeremy-eg9WJcVQRd1EMKyauTCisw@public.gmane.org > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- The years ahead pick up their dark bags. They move closer. There''s a slight rise in the silence then nothing. -- (If you''re receiving this in response to mail sent to bluczkie-OM76b2Iv3yLQjUSlxSEPGw@public.gmane.org, don''t be concerned This is my new address, but mail will be forwarded here indefinitely)
Thank you for your answer ;) But I tested this script before and it doesn''t work :/ I copy the error: script/indexer Searching for Models... Found Configuration - class is not searchable Found Category - class is not searchable Found Link - class is not searchable Found Item - searching columns title,date,category_id,content,author_id - indexed 5 records Found Author - no make_searchable fields Found Comment - no make_searchable fields /usr/lib/ruby/gems/1.8/gems/SimpleSearch-0.5.0/lib/search/simple/searcher.rb:174:in `create_indices'': undefined method `downcase'' for Tue Apr 19 15:06:02 CEST 2005:Time (NoMethodError) from /usr/lib/ruby/gems/1.8/gems/SimpleSearch-0.5.0/lib/search/simple/searcher.rb:171:in `each'' from /usr/lib/ruby/gems/1.8/gems/SimpleSearch-0.5.0/lib/search/simple/searcher.rb:171:in `create_indices'' from /usr/lib/ruby/gems/1.8/gems/SimpleSearch-0.5.0/lib/search/simple/searcher.rb:143:in `load'' from script/indexer:81 And the DB can''t be generated :/ thanks again. Jeremy Hinegardner a écrit :>Hi, > >I left out a very important item in the README. You must first index >your data by running the script/indexer script. This will create the >search_cache file and you shouldn''t get that error anymore. > >I''ll release a new version of the the gem today with some updates. > >enjoy, > >-jeremy > >On Sun, Apr 24, 2005 at 12:13:41PM +0200, Bruno Celeste wrote: > > >>Hi! >> >>I''ve got a problem with the search_generator. I do exactly like the >>README file and it is not working :/ >>When I want to do a search, I go to http://website/search/mykeyword >> >>and the errors returned : >> >> >> NoMethodError in Search#index >> >>undefined method `each'' for #<MockContents:0xb783d52c> >> >>|app/controllers/search_controller.rb:18:in `search'' >>app/controllers/search_controller.rb:7:in `index'' >>script/server:50| >> >> >>The line 18 corresponds to : >> >>simple_index = Search::Simple::Searcher.load(empty_contents,"#{File.dirname(__FILE__)}/../../db/search_cache") >> >> >>The parameters seems to be ok because I have: >> >>*Parameters*: {"search_terms"=>"mykeyword", "count"=>"-1"} >> >>I don''t understand what''s going on in this script :/ >> >>Thanks. >>_______________________________________________ >>Rails mailing list >>Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>http://lists.rubyonrails.org/mailman/listinfo/rails >> >> > > >
Bug are great things aren''t they. Looks like I''ll need to add a to_s() on all fields before passing them into SimpleSearch. I''m guessing your Item.date field is what is causing it. It can''t find a downcase() method on the Time class. I''ll add that in before releasing a new gem. enjoy, -jeremy On Sun, Apr 24, 2005 at 11:14:12PM +0200, Bruno Celeste wrote:> Thank you for your answer ;) > But I tested this script before and it doesn''t work :/ > I copy the error: > > script/indexer > Searching for Models... > Found Configuration > - class is not searchable > Found Category > - class is not searchable > Found Link > - class is not searchable > Found Item > - searching columns title,date,category_id,content,author_id > - indexed 5 records > Found Author > - no make_searchable fields > Found Comment > - no make_searchable fields > /usr/lib/ruby/gems/1.8/gems/SimpleSearch-0.5.0/lib/search/simple/searcher.rb:174:in `create_indices'': undefined method `downcase'' for Tue Apr 19 15:06:02 CEST 2005:Time (NoMethodError) > from /usr/lib/ruby/gems/1.8/gems/SimpleSearch-0.5.0/lib/search/simple/searcher.rb:171:in `each'' > from /usr/lib/ruby/gems/1.8/gems/SimpleSearch-0.5.0/lib/search/simple/searcher.rb:171:in `create_indices'' > from /usr/lib/ruby/gems/1.8/gems/SimpleSearch-0.5.0/lib/search/simple/searcher.rb:143:in `load'' > from script/indexer:81 > > > And the DB can''t be generated :/ > > thanks again. > > Jeremy Hinegardner a écrit : > > >Hi, > > > >I left out a very important item in the README. You must first index > >your data by running the script/indexer script. This will create the > >search_cache file and you shouldn''t get that error anymore. > > > >I''ll release a new version of the the gem today with some updates. > > > >enjoy, > > > >-jeremy > > > >On Sun, Apr 24, 2005 at 12:13:41PM +0200, Bruno Celeste wrote: > > > > > >>Hi! > >> > >>I''ve got a problem with the search_generator. I do exactly like the > >>README file and it is not working :/ > >>When I want to do a search, I go to http://website/search/mykeyword > >> > >>and the errors returned : > >> > >> > >> NoMethodError in Search#index > >> > >>undefined method `each'' for #<MockContents:0xb783d52c> > >> > >>|app/controllers/search_controller.rb:18:in `search'' > >>app/controllers/search_controller.rb:7:in `index'' > >>script/server:50| > >> > >> > >>The line 18 corresponds to : > >> > >>simple_index = Search::Simple::Searcher.load(empty_contents,"#{File.dirname(__FILE__)}/../../db/search_cache") > >> > >> > >>The parameters seems to be ok because I have: > >> > >>*Parameters*: {"search_terms"=>"mykeyword", "count"=>"-1"} > >> > >>I don''t understand what''s going on in this script :/ > >> > >>Thanks. > >>_______________________________________________ > >>Rails mailing list > >>Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > >>http://lists.rubyonrails.org/mailman/listinfo/rails > >> > >> > > > > > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-- ======================================================================= Jeremy Hinegardner jeremy-eg9WJcVQRd1EMKyauTCisw@public.gmane.org
Thank you for this answer :) I upgraded the search generator and I get the same error. I even tried to remove the date field from the searchable fields, but it doesn''t work :/ I copy the error: $ script/indexer Loading config [/home/sadik/ruby/railsBlog/config/search.yml] Searching for Models... Found Configuration - class is not searchable Found Category - class is not searchable Found Link - class is not searchable Found Item - searching columns title,category_id,content,author_id - indexed 5 records Found Author - no make_searchable fields Found Comment - no make_searchable fields creating index file /home/sadik/ruby/railsBlog/db/simple_search_index /usr/lib/ruby/gems/1.8/gems/SimpleSearch-0.5.0/lib/search/simple/searcher.rb:174:in `create_indices'': undefined method `downcase'' for 1:Fixnum (NoMethodError) from /usr/lib/ruby/gems/1.8/gems/SimpleSearch-0.5.0/lib/search/simple/searcher.rb:171:in `each'' from /usr/lib/ruby/gems/1.8/gems/SimpleSearch-0.5.0/lib/search/simple/searcher.rb:171:in `create_indices'' from /usr/lib/ruby/gems/1.8/gems/SimpleSearch-0.5.0/lib/search/simple/searcher.rb:143:in `load'' from script/indexer:91:in `simple_index'' from script/indexer:96 But, if I remove all the fields except ''title'' and ''content'', ie remove all id fields, it does work better, but not perfectly :/ Here the error: $ script/indexer Loading config [/home/sadik/ruby/railsBlog/config/search.yml] Searching for Models... Found Configuration - class is not searchable Found Category - class is not searchable Found Link - class is not searchable Found Item - searching columns title,content - indexed 5 records Found Author - no make_searchable fields Found Comment - no make_searchable fields creating index file /home/sadik/ruby/railsBlog/db/simple_search_index 344 unique words out of 534 in 10 documents /usr/lib/ruby/gems/1.8/gems/SimpleSearch-0.5.0/lib/search/simple/searcher.rb:153:in `initialize'': No such file or directory - ./script/../config/../db/simple_search_index (Errno::ENOENT) from /usr/lib/ruby/gems/1.8/gems/SimpleSearch-0.5.0/lib/search/simple/searcher.rb:153:in `open'' from /usr/lib/ruby/gems/1.8/gems/SimpleSearch-0.5.0/lib/search/simple/searcher.rb:153:in `dump'' from /usr/lib/ruby/gems/1.8/gems/SimpleSearch-0.5.0/lib/search/simple/searcher.rb:148:in `load'' from script/indexer:91:in `simple_index'' from script/indexer:96 Apparently, the script can''t find the database which indexes words... It even doesn''t create the "db" directory so, it''s normal... Thank you again Jeremy ;) Jeremy Hinegardner a écrit :>Bug are great things aren''t they. Looks like I''ll need to add a to_s() on >all fields before passing them into SimpleSearch. I''m guessing your >Item.date field is what is causing it. It can''t find a downcase() >method on the Time class. > >I''ll add that in before releasing a new gem. > >enjoy, > >-jeremy > >On Sun, Apr 24, 2005 at 11:14:12PM +0200, Bruno Celeste wrote: > > >>Thank you for your answer ;) >>But I tested this script before and it doesn''t work :/ >>I copy the error: >> >>script/indexer >>Searching for Models... >> Found Configuration >> - class is not searchable >> Found Category >> - class is not searchable >> Found Link >> - class is not searchable >> Found Item >> - searching columns title,date,category_id,content,author_id >> - indexed 5 records >> Found Author >> - no make_searchable fields >> Found Comment >> - no make_searchable fields >>/usr/lib/ruby/gems/1.8/gems/SimpleSearch-0.5.0/lib/search/simple/searcher.rb:174:in `create_indices'': undefined method `downcase'' for Tue Apr 19 15:06:02 CEST 2005:Time (NoMethodError) >> from /usr/lib/ruby/gems/1.8/gems/SimpleSearch-0.5.0/lib/search/simple/searcher.rb:171:in `each'' >> from /usr/lib/ruby/gems/1.8/gems/SimpleSearch-0.5.0/lib/search/simple/searcher.rb:171:in `create_indices'' >> from /usr/lib/ruby/gems/1.8/gems/SimpleSearch-0.5.0/lib/search/simple/searcher.rb:143:in `load'' >> from script/indexer:81 >> >> >>And the DB can''t be generated :/ >> >>thanks again. >> >>Jeremy Hinegardner a écrit : >> >> >> >>>Hi, >>> >>>I left out a very important item in the README. You must first index >>>your data by running the script/indexer script. This will create the >>>search_cache file and you shouldn''t get that error anymore. >>> >>>I''ll release a new version of the the gem today with some updates. >>> >>>enjoy, >>> >>>-jeremy >>> >>>On Sun, Apr 24, 2005 at 12:13:41PM +0200, Bruno Celeste wrote: >>> >>> >>> >>> >>>>Hi! >>>> >>>>I''ve got a problem with the search_generator. I do exactly like the >>>>README file and it is not working :/ >>>>When I want to do a search, I go to http://website/search/mykeyword >>>> >>>>and the errors returned : >>>> >>>> >>>> NoMethodError in Search#index >>>> >>>>undefined method `each'' for #<MockContents:0xb783d52c> >>>> >>>>|app/controllers/search_controller.rb:18:in `search'' >>>>app/controllers/search_controller.rb:7:in `index'' >>>>script/server:50| >>>> >>>> >>>>The line 18 corresponds to : >>>> >>>>simple_index = Search::Simple::Searcher.load(empty_contents,"#{File.dirname(__FILE__)}/../../db/search_cache") >>>> >>>> >>>>The parameters seems to be ok because I have: >>>> >>>>*Parameters*: {"search_terms"=>"mykeyword", "count"=>"-1"} >>>> >>>>I don''t understand what''s going on in this script :/ >>>> >>>>Thanks. >>>>_______________________________________________ >>>>Rails mailing list >>>>Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>>>http://lists.rubyonrails.org/mailman/listinfo/rails >>>> >>>> >>>> >>>> >>> >>> >>> >>> >>_______________________________________________ >>Rails mailing list >>Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>http://lists.rubyonrails.org/mailman/listinfo/rails >> >> > > >
So, I successed :p In fact, I create the dir "db" and the file "simple_search_index" and it works perfectly! I have always the same error if I want to search in ID field or date field... but it''s not very important to me. Bruno Celeste a écrit :>Thank you for this answer :) >I upgraded the search generator and I get the same error. I even tried >to remove the date field from the searchable fields, but it doesn''t work :/ > >I copy the error: > >$ script/indexer > >Loading config [/home/sadik/ruby/railsBlog/config/search.yml] > >Searching for Models... > > Found Configuration > > - class is not searchable > > Found Category > > - class is not searchable > > Found Link > > - class is not searchable > > Found Item > > - searching columns title,category_id,content,author_id > > - indexed 5 records > > Found Author > > - no make_searchable fields > > Found Comment > > - no make_searchable fields > >creating index file /home/sadik/ruby/railsBlog/db/simple_search_index > >/usr/lib/ruby/gems/1.8/gems/SimpleSearch-0.5.0/lib/search/simple/searcher.rb:174:in `create_indices'': undefined method `downcase'' for 1:Fixnum (NoMethodError) > > from /usr/lib/ruby/gems/1.8/gems/SimpleSearch-0.5.0/lib/search/simple/searcher.rb:171:in `each'' > > from /usr/lib/ruby/gems/1.8/gems/SimpleSearch-0.5.0/lib/search/simple/searcher.rb:171:in `create_indices'' > > from /usr/lib/ruby/gems/1.8/gems/SimpleSearch-0.5.0/lib/search/simple/searcher.rb:143:in `load'' > > from script/indexer:91:in `simple_index'' > > from script/indexer:96 > > >But, if I remove all the fields except ''title'' and ''content'', ie remove >all id fields, it does work better, but not perfectly :/ >Here the error: > >$ script/indexer > >Loading config [/home/sadik/ruby/railsBlog/config/search.yml] > >Searching for Models... > > Found Configuration > > - class is not searchable > > Found Category > > - class is not searchable > > Found Link > > - class is not searchable > > Found Item > > - searching columns title,content > > - indexed 5 records > > Found Author > > - no make_searchable fields > > Found Comment > > - no make_searchable fields > >creating index file /home/sadik/ruby/railsBlog/db/simple_search_index > >344 unique words out of 534 in 10 documents > >/usr/lib/ruby/gems/1.8/gems/SimpleSearch-0.5.0/lib/search/simple/searcher.rb:153:in `initialize'': No such file or directory - ./script/../config/../db/simple_search_index (Errno::ENOENT) > > from /usr/lib/ruby/gems/1.8/gems/SimpleSearch-0.5.0/lib/search/simple/searcher.rb:153:in `open'' > > from /usr/lib/ruby/gems/1.8/gems/SimpleSearch-0.5.0/lib/search/simple/searcher.rb:153:in `dump'' > > from /usr/lib/ruby/gems/1.8/gems/SimpleSearch-0.5.0/lib/search/simple/searcher.rb:148:in `load'' > > from script/indexer:91:in `simple_index'' > > from script/indexer:96 > > >Apparently, the script can''t find the database which indexes words... It >even doesn''t create the "db" directory so, it''s normal... > >Thank you again Jeremy ;) > > >Jeremy Hinegardner a écrit : > > > >>Bug are great things aren''t they. Looks like I''ll need to add a to_s() on >>all fields before passing them into SimpleSearch. I''m guessing your >>Item.date field is what is causing it. It can''t find a downcase() >>method on the Time class. >> >>I''ll add that in before releasing a new gem. >> >>enjoy, >> >>-jeremy >> >>On Sun, Apr 24, 2005 at 11:14:12PM +0200, Bruno Celeste wrote: >> >> >> >> >>>Thank you for your answer ;) >>>But I tested this script before and it doesn''t work :/ >>>I copy the error: >>> >>>script/indexer >>>Searching for Models... >>> Found Configuration >>> - class is not searchable >>> Found Category >>> - class is not searchable >>> Found Link >>> - class is not searchable >>> Found Item >>> - searching columns title,date,category_id,content,author_id >>> - indexed 5 records >>> Found Author >>> - no make_searchable fields >>> Found Comment >>> - no make_searchable fields >>>/usr/lib/ruby/gems/1.8/gems/SimpleSearch-0.5.0/lib/search/simple/searcher.rb:174:in `create_indices'': undefined method `downcase'' for Tue Apr 19 15:06:02 CEST 2005:Time (NoMethodError) >>> from /usr/lib/ruby/gems/1.8/gems/SimpleSearch-0.5.0/lib/search/simple/searcher.rb:171:in `each'' >>> from /usr/lib/ruby/gems/1.8/gems/SimpleSearch-0.5.0/lib/search/simple/searcher.rb:171:in `create_indices'' >>> from /usr/lib/ruby/gems/1.8/gems/SimpleSearch-0.5.0/lib/search/simple/searcher.rb:143:in `load'' >>> from script/indexer:81 >>> >>> >>>And the DB can''t be generated :/ >>> >>>thanks again. >>> >>>Jeremy Hinegardner a écrit : >>> >>> >>> >>> >>> >>>>Hi, >>>> >>>>I left out a very important item in the README. You must first index >>>>your data by running the script/indexer script. This will create the >>>>search_cache file and you shouldn''t get that error anymore. >>>> >>>>I''ll release a new version of the the gem today with some updates. >>>> >>>>enjoy, >>>> >>>>-jeremy >>>> >>>>On Sun, Apr 24, 2005 at 12:13:41PM +0200, Bruno Celeste wrote: >>>> >>>> >>>> >>>> >>>> >>>> >>>>>Hi! >>>>> >>>>>I''ve got a problem with the search_generator. I do exactly like the >>>>>README file and it is not working :/ >>>>>When I want to do a search, I go to http://website/search/mykeyword >>>>> >>>>>and the errors returned : >>>>> >>>>> >>>>>NoMethodError in Search#index >>>>> >>>>>undefined method `each'' for #<MockContents:0xb783d52c> >>>>> >>>>>|app/controllers/search_controller.rb:18:in `search'' >>>>>app/controllers/search_controller.rb:7:in `index'' >>>>>script/server:50| >>>>> >>>>> >>>>>The line 18 corresponds to : >>>>> >>>>>simple_index = Search::Simple::Searcher.load(empty_contents,"#{File.dirname(__FILE__)}/../../db/search_cache") >>>>> >>>>> >>>>>The parameters seems to be ok because I have: >>>>> >>>>>*Parameters*: {"search_terms"=>"mykeyword", "count"=>"-1"} >>>>> >>>>>I don''t understand what''s going on in this script :/ >>>>> >>>>>Thanks. >>>>>_______________________________________________ >>>>>Rails mailing list >>>>>Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>>>>http://lists.rubyonrails.org/mailman/listinfo/rails >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>> >>>> >>>> >>>> >>>_______________________________________________ >>>Rails mailing list >>>Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>>http://lists.rubyonrails.org/mailman/listinfo/rails >>> >>> >>> >>> >> >> >> >> >_______________________________________________ >Rails mailing list >Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >http://lists.rubyonrails.org/mailman/listinfo/rails > > >