Skip to content

Instantly share code, notes, and snippets.

@f440
Created February 16, 2014 10:34
Show Gist options
  • Save f440/9032243 to your computer and use it in GitHub Desktop.
Save f440/9032243 to your computer and use it in GitHub Desktop.
Import to ElasticSearch from Pinboard
#!/usr/bin/env ruby
require 'rexml/document'
require 'elasticsearch'
doc = REXML::Document.new(open(ARGV[0]).read)
es = Elasticsearch::Client.new log: true
doc.elements.each('/posts/post') do |element|
# attributes: [href, time, description, extended, tag, hash, shared]
next if element.attributes["shared"]
es.create index: "bookmark",
type: "bookmark",
body: {
url: element.attributes["href"],
description: element.attributes["description"],
time: DateTime.parse(element.attributes["time"]).iso8601,
tag: element.attributes["tag"].split
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment