Created
July 29, 2011 09:42
-
-
Save biilmann/1113531 to your computer and use it in GitHub Desktop.
Indexing stuff
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Content | |
| # ... | |
| def to_indexed_json | |
| { | |
| :type => "content", | |
| :id => id, | |
| :project_id => id, | |
| :section_id => section_id, | |
| :category_id => attributes["category_id"], | |
| :published => published, | |
| :title => title, | |
| :description => description, | |
| :created_at => created_at, | |
| :published_at => published_at, | |
| :updated_at => updated_at, | |
| :slug => slug | |
| } | |
| end | |
| end | |
| Tire.configure { logger $stdout, :level => 'debug' } | |
| Tire.index "contents" do | |
| delete | |
| create :mappings => { | |
| :content => { | |
| :date_formats => ["yyyy/MM/dd HH:mm:ss Z"], | |
| :properties => { | |
| :id => { :type => "string", :index => "not_analyzed", :include_in_all => false}, | |
| :project_id => { :type => "string", :include_in_all => false}, | |
| :section_id => { :type => "string", :include_in_all => false}, | |
| :category_id => { :type => "string", :include_in_all => false}, | |
| :published => { :type => "boolean", :include_in_all => false}, | |
| :title => { :type => "string", :boost => 2.0, :analyzer => "snowball"}, | |
| :description => { :type => "string", :analyzer => "snowball"}, | |
| :created_at => { :type => "date", :include_in_all => false}, | |
| :published_at => { :type => "date", :include_in_all => false}, | |
| :updated_at => { :type => "date" }, | |
| :slug => { :type => "string", :analyzer => "keyword"} | |
| } | |
| } | |
| } | |
| Content.all.each do |content| | |
| puts "Storing #{content.permalink}" | |
| store content.to_indexed_json | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (master) MBCBook-Pro:prim-soup mbc$ ruby db/migrations/index_contents.rb | |
| # 2011-07-29 11:44:07:543 [DELETE] ("contents") | |
| # | |
| curl -X DELETE "http://localhost:9200/contents" | |
| # 2011-07-29 11:44:07:552 [200] | |
| # | |
| # null | |
| # 2011-07-29 11:44:07:672 [CREATE] ("contents") | |
| # | |
| curl -X POST "http://localhost:9200/contents" -d '{"mappings":{"content":{"date_formats":["yyyy/MM/dd HH:mm:ss Z"],"properties":{"id":{"type":"string","index":"not_analyzed","include_in_all":false},"project_id":{"type":"string","include_in_all":false},"section_id":{"type":"string","include_in_all":false},"category_id":{"type":"string","include_in_all":false},"published":{"type":"boolean","include_in_all":false},"title":{"type":"string","boost":2.0,"analyzer":"snowball"},"description":{"type":"string","analyzer":"snowball"},"created_at":{"type":"date","include_in_all":false},"published_at":{"type":"date","include_in_all":false},"updated_at":{"type":"date"},"slug":{"type":"string","analyzer":"keyword"}}}}}' | |
| # 2011-07-29 11:44:07:672 [200] | |
| # | |
| # null | |
| Storing /scarves/bestsellers | |
| # 2011-07-29 11:44:07:766 [/contents/content/] ("contents") | |
| # | |
| curl -X POST "http://localhost:9200/contents/content/4c4ee42922234e4afb000142" -d '{"id":"4c4ee42922234e4afb000142","project_id":"4c4ee42922234e4afb000142","section_id":"4c4ee42922234e4afb00009f","category_id":null,"published":true,"title":"Bestsellers","description":null,"created_at":"2010/07/27 15:50:33 +0200","published_at":"2010/07/27 15:50:33 +0200","updated_at":"2011/07/13 18:08:00 +0200","slug":"bestsellers"}' | |
| # 2011-07-29 11:44:07:766 [200] | |
| # | |
| # null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment