From 9142ba9dd466c4dd2d79dcfc8c056adecd5e79bc Mon Sep 17 00:00:00 2001 From: Kerollmops Date: Wed, 2 Feb 2022 17:55:13 +0100 Subject: [PATCH] Fix the parsing of ndjson requests to index more than the first line --- http-ui/src/main.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/http-ui/src/main.rs b/http-ui/src/main.rs index 039a6c2ae..ebfe4b073 100644 --- a/http-ui/src/main.rs +++ b/http-ui/src/main.rs @@ -1063,12 +1063,11 @@ fn documents_from_jsonl(reader: impl io::Read) -> anyhow::Result> { 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())