Method: AWSCloudSearch::DocumentBatch#add_document
- Defined in:
- lib/aws_cloud_search/document_batch.rb
#add_document(doc) ⇒ Object
Adds a document with the add operation to the batch.
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/aws_cloud_search/document_batch.rb', line 26 def add_document(doc) raise ArgumentError.new("Invalid Type") unless doc.is_a? Document doc.type = 'add' json = doc.to_json doc_bytesize = json.bytesize raise Exception.new("Max batch size exceeded, document add was not added to batch.") if (doc_bytesize + @bytesize) > @max_bytesize raise ArgumentError.new("Found invalid XML 1.0 unicode characters.") if json =~ INVALID_CHAR_XML10 @bytesize += doc_bytesize @batch_add << doc end |