|
122 | 122 | let(:csv_docs) do |
123 | 123 | <<~CSV |
124 | 124 | "objectRef:number","title:string","comment:string" |
125 | | - "1239","Pride and Prejudice","A great book" |
| 125 | + "123","Pride and Prejudice","A great book" |
126 | 126 | "456","Le Petit Prince","A french book" |
127 | 127 | "49","Harry Potter and the Half-Blood Prince","The best book" |
128 | 128 | "55","The Three Body Problem","An interesting book" |
|
133 | 133 | let(:csv_docs_custom_delim) do |
134 | 134 | <<~CSV |
135 | 135 | "objectRef:number"|"title:string"|"comment:string" |
136 | | - "1239"|"Pride and Prejudice"|"A great book" |
| 136 | + "123"|"Pride and Prejudice"|"A great book" |
137 | 137 | "456"|"Le Petit Prince"|"A french book" |
138 | 138 | "49"|"Harry Potter and the Half-Blood Prince"|"The best book" |
139 | 139 | "55"|"The Three Body Problem"|"An interesting book" |
|
199 | 199 |
|
200 | 200 | expect(index.documents['results']).to include(batch1_doc, batch2_doc) |
201 | 201 | end |
| 202 | + |
| 203 | + it '#update_documents_json' do |
| 204 | + index.add_documents_json(json_docs, 'objectRef').await |
| 205 | + edit = '[{ "objectRef": 123, "comment": "AN OLD BOOK" }]' |
| 206 | + index.update_documents_json(edit).await |
| 207 | + expect(index.documents['results']).to include( |
| 208 | + { |
| 209 | + 'objectRef' => 123, |
| 210 | + 'title' => 'Pride and Prejudice', |
| 211 | + 'comment' => 'AN OLD BOOK' |
| 212 | + } |
| 213 | + ) |
| 214 | + end |
| 215 | + |
| 216 | + it '#update_documents_ndjson' do |
| 217 | + index.add_documents_ndjson(ndjson_docs, 'objectRef').await |
| 218 | + edit = '{ "objectRef": 123, "comment": "AN OLD BOOK" }' |
| 219 | + index.update_documents_ndjson(edit).await |
| 220 | + expect(index.documents['results']).to include( |
| 221 | + { |
| 222 | + 'objectRef' => 123, |
| 223 | + 'title' => 'Pride and Prejudice', |
| 224 | + 'comment' => 'AN OLD BOOK' |
| 225 | + } |
| 226 | + ) |
| 227 | + end |
| 228 | + |
| 229 | + it '#update_documents_csv' do |
| 230 | + index.add_documents_csv(csv_docs, 'objectRef').await |
| 231 | + edit = <<~CSV |
| 232 | + "objectRef:number","comment:string" |
| 233 | + "123","AN OLD BOOK" |
| 234 | + CSV |
| 235 | + |
| 236 | + index.update_documents_csv(edit).await |
| 237 | + expect(index.documents['results']).to include( |
| 238 | + { |
| 239 | + 'objectRef' => 123, |
| 240 | + 'title' => 'Pride and Prejudice', |
| 241 | + 'comment' => 'AN OLD BOOK' |
| 242 | + } |
| 243 | + ) |
| 244 | + end |
| 245 | + |
| 246 | + it '#update_documents_csv with custom delimiter' do |
| 247 | + index.add_documents_csv(csv_docs, 'objectRef').await |
| 248 | + edit = <<~CSV |
| 249 | + "objectRef:number"|"comment:string" |
| 250 | + "123"|"AN OLD BOOK" |
| 251 | + CSV |
| 252 | + |
| 253 | + index.update_documents_csv(edit, 'objectRef', '|').await |
| 254 | + expect(index.documents['results']).to include( |
| 255 | + { |
| 256 | + 'objectRef' => 123, |
| 257 | + 'title' => 'Pride and Prejudice', |
| 258 | + 'comment' => 'AN OLD BOOK' |
| 259 | + } |
| 260 | + ) |
| 261 | + end |
202 | 262 | end |
203 | 263 |
|
204 | 264 | describe '#add_documents!' do |
|
0 commit comments