Sha256: da0b0cfdb8f802227087deccf8c5afceeb852987d8c891adc2039e5636781c4d
Contents?: true
Size: 905 Bytes
Versions: 7
Compression:
Stored size: 905 Bytes
Contents
require 'excon' module Inquisitio class Indexer def self.index(documents) new(documents).index end def initialize(documents) raise InquisitioError.new("Document(s) is null") if documents.nil? raise InquisitioError.new("Document(s) is empty") unless documents.any? @documents = documents end def index response = Excon.post(batch_index_url, :body => body, :headers => {"Content-Type" =>"application/json"}) raise InquisitioError.new("Index failed with status code: #{response.status} Message: #{response.body}") unless response.status == 200 response.body end private def body body = @documents.map(&:to_SDF).join(", ") "[#{body}]" end def batch_index_url "#{Inquisitio.config.document_endpoint}/2011-02-01/documents/batch" end end end
Version data entries
7 entries across 7 versions & 1 rubygems