Fix the parsing of ndjson requests to index more than the first line

This commit is contained in:
Kerollmops 2022-02-02 17:55:13 +01:00
parent 38d23546a5
commit 9142ba9dd4
No known key found for this signature in database
GPG Key ID: 92ADA4E935E71FA4

View File

@ -1063,12 +1063,11 @@ fn documents_from_jsonl(reader: impl io::Read) -> anyhow::Result<Vec<u8>> {
let mut writer = Cursor::new(Vec::new());
let mut documents = milli::documents::DocumentBatchBuilder::new(&mut writer)?;
let mut buf = String::new();
let mut reader = BufReader::new(reader);
while reader.read_line(&mut buf)? > 0 {
documents.extend_from_json(&mut buf.as_bytes())?;
for result in BufReader::new(reader).lines() {
let line = result?;
documents.extend_from_json(Cursor::new(line))?;
}
documents.finish()?;
Ok(writer.into_inner())