Big JSON file to be splitted into multiple sub files and ingest via mlcp

37 views Asked by At

I have json file as below -

{
"items" : [ {
  "book" : 'abc'
},
{
  "book" : '123'
},{
  "book" : 'xyz'
}
]

}

I used below mlcp command but getting error like "leading space".

mlcp.bat import -host localhost -port 7003 -username admin -password admin -input_file_path C:\CR -input_file_type delimited_json

what is the best way to load this json file as multiple file for each book field. So post ingestion I should have 3 files, one for each book field.

1

There are 1 answers

10
Mads Hansen On

MLCP expects each line in the file of a delimited_json to be a line of JSON.

https://docs.marklogic.com/11.0/guide/mlcp-guide/en/importing-content-into-marklogic-server/creating-documents-from-line-delimited-json-files/line-delimited-json-overview.html

A line-delimited JSON file is a type of aggregate file where each line is a self-contained piece of JSON data, such as an object or array.

It isn't going to parse the JSON doc and read the items array as separate docs.

You can achieve that in a custom ingest transform though. This similar question has an example demonstrating how to read the JSON and create a document for each item in an array: https://stackoverflow.com/a/36506478/14419