|
34 | 34 | expect(index.documents['results'].first.keys).to eq(doc.keys.map(&:to_s)) |
35 | 35 | end |
36 | 36 |
|
37 | | - it 'adds JSON documents' do |
38 | | - documents = <<~JSON |
39 | | - [ |
40 | | - { "objectRef": 123, "title": "Pride and Prejudice", "comment": "A great book" }, |
41 | | - { "objectRef": 456, "title": "Le Petit Prince", "comment": "A french book" }, |
42 | | - { "objectRef": 1, "title": "Alice In Wonderland", "comment": "A weird book" }, |
43 | | - { "objectRef": 1344, "title": "The Hobbit", "comment": "An awesome book" }, |
44 | | - { "objectRef": 4, "title": "Harry Potter and the Half-Blood Prince", "comment": "The best book" } |
45 | | - ] |
46 | | - JSON |
47 | | - index.add_documents_json(documents, 'objectRef').await |
48 | | - |
49 | | - expect(index.documents['results'].count).to eq(5) |
50 | | - end |
51 | | - |
52 | 37 | it 'infers order of fields' do |
53 | 38 | index.add_documents(documents).await |
54 | 39 | task = index.document(1) |
|
132 | 117 | NDJSON |
133 | 118 | end |
134 | 119 |
|
| 120 | + let(:json_docs) { "[#{ndjson_docs.rstrip.gsub("\n", ',')}]" } |
| 121 | + |
135 | 122 | let(:csv_docs) do |
136 | 123 | <<~CSV |
137 | 124 | "objectRef:number","title:string","comment:string" |
|
170 | 157 | } |
171 | 158 | end |
172 | 159 |
|
| 160 | + it '#add_documents_json' do |
| 161 | + index.add_documents_json(json_docs, 'objectRef').await |
| 162 | + expect(index.documents['results'].count).to eq(5) |
| 163 | + end |
| 164 | + |
173 | 165 | it '#add_documents_ndjson' do |
174 | 166 | index.add_documents_ndjson(ndjson_docs, 'objectRef').await |
175 | 167 |
|
|
0 commit comments