Created
October 25, 2013 03:50
-
-
Save tsunagun/7149212 to your computer and use it in GitHub Desktop.
Solrのdateフィールドに入力する値のフォーマットについて
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
require 'rsolr' | |
require 'time' | |
mode = ARGV[0] || "1" | |
url = case mode | |
when "1" | |
"http://localhost:8983/solr/collection1" | |
when "2" | |
"http://localhost:8983/solr/collection2" | |
end | |
solr = RSolr.connect :url => url | |
instances = case mode | |
when "1" | |
(1..5).map do |i| | |
{ | |
uri: "http://example.com/resource/#{i}", | |
label: "リソース#{i}のラベル", | |
description: "リソース#{i}の概要をここに書く", | |
last_modified: Time.now.strftime("%Y-%m-%dT%H:%M:%SZ-9HOUR"), | |
links: [ | |
"http://example.com/link/from/#{i}/to/1", | |
"http://example.com/link/from/#{i}/to/2", | |
"http://example.com/link/from/#{i}/to/3", | |
] | |
} | |
end | |
when "2" | |
(1..5).map do |i| | |
{ | |
id: "#{i}", | |
title: "id#{i}で識別されるリソースのタイトル", | |
body: "リソース#{i}の内容をここに書く", | |
last_modified: Time.now.strftime("%Y-%m-%dT%H:%M:%SZ-9HOUR"), | |
} | |
end | |
end | |
solr.add(instances) | |
solr.commit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment