Skip to content

Working with JSON LD

geraldhiebel edited this page May 20, 2015 · 22 revisions

Converting JSON-LD to One Object Per Line

  1. Download and install jq from http://stedolan.github.io/jq/
  2. To convert JSON Array to one json object per line from command line
   jq ".[]" -c <filepath> > <outputfilepath>

Merging JSON-LD Files

Loading JSON-LD into Elastic Search

  1. git clone https://github.com/usc-isi-i2/dig-elasticsearch.git
  2. Change directory to types/webpage/scripts
  3. Type python loadDataElasticSearch.py -h. This will provide help for the script as below
   usage: loadDataElasticSearch.py [-h] [-hostname HOSTNAME] [-port PORT]
                                   [-mappingFilePath MAPPINGFILEPATH] dataFileType
                                filepath indexname doctype

   positional arguments:
      filepath            json file to be loaded in ElasticSearch
      indexname           desired name of the index in ElasticSearch
      doctype             type of the document to be indexed
      dataFileType        Specify '0' if every line in the data file is
                          different json object or '1' otherwise

   optional arguments:
      -h, --help                       show this help message and exit
      -hostname HOSTNAME               Elastic Search Server hostname, defaults to 'localhost'
      -port PORT                       Elastic Search Server port,defaults to 9200
      -mappingFilePath MAPPINGFILEPATH mapping/setting file for the index

d. Execute:

python loadDataElasticSearch.py <filepath> <index-name> WebPage

If you don't have Elastic Search please download it from https://www.elastic.co/products/elasticsearch and follow the installation instructions.