File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 167167# "num_employees" => 5215
168168# }
169169
170+ # You can also upsert a document, by providing it as an option
171+ # document = @typesense.collections['companies'].documents.create(document, upsert: true)
172+ # ap document
173+
170174##
171175# Retrieve a document
172176sleep 0.5 # Give Typesense cluster a few hundred ms to create the document on all nodes, before reading it right after (eventually consistent)
180184# "num_employees" => 5215
181185# }
182186
187+ ##
188+ # Update a document
189+ document = @typesense . collections [ 'companies' ] . documents [ '124' ] . update (
190+ 'id' => '124' ,
191+ 'num_employees' => 550
192+ )
193+ ap document
194+
195+ # {
196+ # "id" => "124",
197+ # "num_employees" => 5500
198+ # }
199+
183200##
184201# Delete a document
185202# Deleting a document, returns the document after deletion
213230## If you already have documents in JSONL format, you can also use #import instead, to avoid the JSON parsing overhead:
214231# @typesense.collections['companies'].documents.import(documents_in_jsonl_format)
215232
233+ ## You can also bulk upsert documents, by adding an upsert option to #create_many or #import
234+ # @typesense.collections['companies'].documents.create_many(documents, upsert: true)
235+ # @typesense.collections['companies'].documents.import(documents_in_jsonl_format, upsert: true)
236+
216237##
217238# Export all documents in a collection in JSON Lines format
218239# We use JSON Lines format for performance reasons. You can choose to parse selected lines as needed, by splitting on \n.
You can’t perform that action at this time.
0 commit comments