Commit ddab0f05 authored by Daniel Witek's avatar Daniel Witek

small update

parent 3623a024
......@@ -6,25 +6,29 @@ const request = require('sync-request')
let documents = []
// read file through fs readstream
const instream = fs.createReadStream('pokemon.json') // simplewiki file has to be named 'simplewiki.json'
const instream = fs.createReadStream('minijson.json') // simplewiki file has to be named 'simplewiki.json'
const outstream = new stream
const rl = readline.createInterface(instream, outstream)
// do this for every line in the stream
rl.on('line', function(line) {
// only every second line is interesting -> lines starting with index are not interesting
if(line.substring(0, 8) == '{"index"') return
else {
// extract only the relevant properties of the input JSON file
if (line.length < 4) {
return
}
else {
const lineJson = JSON.parse(line);
const outJson = {}
// write relevant properties to output JSON file
outJson["poke_id"] = lineJson.Number
outJson["poke_txt_en"] = lineJson.Name
outJson["gen_txt_en"] = lineJson.Generation
outJson["about_txt_en"] = lineJson.About
outJson["types_features"] = lineJson.Types
outJson["poke_id"] = lineJson.number
outJson["poke_txt_en"] = lineJson.name
outJson["gen_txt_en"] = lineJson.generation
outJson["about_txt_en"] = lineJson.about
outJson["types_features"] = lineJson.types
/*
// opening_text is optional
......@@ -37,7 +41,8 @@ rl.on('line', function(line) {
//accumulate JSON objects before they are sent
accumData(outJson)
}
console.log(outJson);
}
})
......@@ -69,10 +74,11 @@ function sendData(postData){
}
}
// on response from server, log response
let response = request('POST', 'http://localhost:8983/solr/gettingstarted/update/json/docs?commit=true&overwrite=true', clientServerOptions);
// let response = request('POST', 'http://localhost:8983/solr/gettingstarted/update/json/docs?commit=true&overwrite=true', clientServerOptions);
if (response.statusCode !== 200) {
throw(response.body)
} else {
console.log('sent')
}
}
\ No newline at end of file
}
[
{
"Number": "001",
"Name": "Bulbasaur",
"Generation": "Generation I",
"About": "Bulbasaur can be seen napping in bright sunlight. There is a seed on its back. By soaking up the sun's rays, the seed grows progressively larger.",
"Types": [
"Grass",
"Poison"
]
},
{
"Number": "002",
"Name": "Ivysaur",
"Generation": "Generation I",
"About": "There is a bud on this Pok\u00e9mon's back. To support its weight, Ivysaur's legs and trunk grow thick and strong. If it starts spending more time lying in the sunlight, it's a sign that the bud will bloom into a large flower soon.",
"Types": [
"Grass",
"Poison"
]
},
{
"Number": "003",
"Name": "Venusaur",
"Generation": "Generation I",
"About": "There is a large flower on Venusaur's back. The flower is said to take on vivid colors if it gets plenty of nutrition and sunlight. The flower's aroma soothes the emotions of people.",
"Types": [
"Grass",
"Poison"
]
}
]
\ No newline at end of file
[{
"number":"001",
"name": "Bulbasaur",
"generation": "Generation I",
"about": "Bulbasaur can be seen napping in bright sunlight. There is a seed on its back. By soaking up the sun's rays, the seed grows progressively larger.",
"types": ["Grass","Poison"]
},{
"number": "002",
"name": "Ivysaur",
"generation": "Generation I",
"about": "There is a bud on this Pokemon's back. To support its weight, Ivysaur's legs and trunk grow thick and strong. If it starts spending more time lying in the sunlight, it's a sign that the bud will bloom into a large flower soon.",
"types": ["Grass","Poison"]
},{
"number": "003",
"name": "Venusaur",
"generation": "Generation I",
"about": "There is a large flower on Venusaur's back. The flower is said to take on vivid colors if it gets plenty of nutrition and sunlight. The flower's aroma soothes the emotions of people.",
"types": ["Grass","Poison"]
}]
......@@ -9,7 +9,7 @@
"resolved": "https://registry.npmjs.org/@types/concat-stream/-/concat-stream-1.6.0.tgz",
"integrity": "sha1-OU2+C7X+5Gs42JZzXoto7yOQ0A0=",
"requires": {
"@types/node": "*"
"@types/node": "9.6.21"
}
},
"@types/form-data": {
......@@ -17,7 +17,7 @@
"resolved": "https://registry.npmjs.org/@types/form-data/-/form-data-0.0.33.tgz",
"integrity": "sha1-yayFsqX9GENbjIXZ7LUObWyJP/g=",
"requires": {
"@types/node": "*"
"@types/node": "9.6.21"
}
},
"@types/node": {
......@@ -45,8 +45,8 @@
"resolved": "https://registry.npmjs.org/axios/-/axios-0.17.1.tgz",
"integrity": "sha1-LY4+XQvb1zJ/kbyBT1xXZg+Bgk0=",
"requires": {
"follow-redirects": "^1.2.5",
"is-buffer": "^1.1.5"
"follow-redirects": "1.5.0",
"is-buffer": "1.1.6"
}
},
"buffer-from": {
......@@ -64,7 +64,7 @@
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz",
"integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=",
"requires": {
"delayed-stream": "~1.0.0"
"delayed-stream": "1.0.0"
}
},
"commander": {
......@@ -77,10 +77,10 @@
"resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz",
"integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==",
"requires": {
"buffer-from": "^1.0.0",
"inherits": "^2.0.3",
"readable-stream": "^2.2.2",
"typedarray": "^0.0.6"
"buffer-from": "1.1.0",
"inherits": "2.0.3",
"readable-stream": "2.3.6",
"typedarray": "0.0.6"
}
},
"core-util-is": {
......@@ -111,7 +111,7 @@
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.0.tgz",
"integrity": "sha512-fdrt472/9qQ6Kgjvb935ig6vJCuofpBUD14f9Vb+SLlm7xIe4Qva5gey8EKtv8lp7ahE1wilg3xL1znpVGtZIA==",
"requires": {
"debug": "^3.1.0"
"debug": "3.1.0"
}
},
"form-data": {
......@@ -119,9 +119,9 @@
"resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.2.tgz",
"integrity": "sha1-SXBJi+YEwgwAXU9cI67NIda0kJk=",
"requires": {
"asynckit": "^0.4.0",
"asynckit": "0.4.0",
"combined-stream": "1.0.6",
"mime-types": "^2.1.12"
"mime-types": "2.1.18"
}
},
"fs": {
......@@ -139,12 +139,12 @@
"resolved": "https://registry.npmjs.org/http-basic/-/http-basic-7.0.0.tgz",
"integrity": "sha1-gvClBr6UJzLsje6+6A50bvVzbbo=",
"requires": {
"@types/concat-stream": "^1.6.0",
"@types/node": "^9.4.1",
"caseless": "~0.12.0",
"concat-stream": "^1.4.6",
"http-response-object": "^3.0.1",
"parse-cache-control": "^1.0.1"
"@types/concat-stream": "1.6.0",
"@types/node": "9.6.21",
"caseless": "0.12.0",
"concat-stream": "1.6.2",
"http-response-object": "3.0.1",
"parse-cache-control": "1.0.1"
}
},
"http-response-object": {
......@@ -152,7 +152,7 @@
"resolved": "https://registry.npmjs.org/http-response-object/-/http-response-object-3.0.1.tgz",
"integrity": "sha512-6L0Fkd6TozA8kFSfh9Widst0wfza3U1Ex2RjJ6zNDK0vR1U1auUR6jY4Nn2Xl7CCy0ikFmxW1XcspVpb9RvwTg==",
"requires": {
"@types/node": "^9.3.0"
"@types/node": "9.6.21"
}
},
"immediate": {
......@@ -180,7 +180,7 @@
"resolved": "https://registry.npmjs.org/lie/-/lie-3.1.1.tgz",
"integrity": "sha1-mkNrLMd0bKWd56QfpGmz77dr2H4=",
"requires": {
"immediate": "~3.0.5"
"immediate": "3.0.6"
}
},
"localforage": {
......@@ -201,7 +201,7 @@
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz",
"integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==",
"requires": {
"mime-db": "~1.33.0"
"mime-db": "1.33.0"
}
},
"ms": {
......@@ -219,9 +219,9 @@
"resolved": "https://registry.npmjs.org/pokeapi/-/pokeapi-0.0.1.tgz",
"integrity": "sha1-uW6SUQ5yGgESSsQEZ/ptDjjS++c=",
"requires": {
"commander": "^2.7.1",
"rest": "^1.3.0",
"when": "^3.7.2"
"commander": "2.15.1",
"rest": "1.3.2",
"when": "3.7.8"
}
},
"pokeapi-js-wrapper": {
......@@ -229,8 +229,8 @@
"resolved": "https://registry.npmjs.org/pokeapi-js-wrapper/-/pokeapi-js-wrapper-1.1.1.tgz",
"integrity": "sha512-AdRKmhq7lR6NeieH0Q1E1rlqvRzszDH3O6YNUjwOBYqSUUDgP3CR6oUKglRGLrqQB70F1ySV//DyZ1H/hhxf+w==",
"requires": {
"axios": "^0.17.0",
"localforage": "^1.5.0"
"axios": "0.17.1",
"localforage": "1.7.1"
}
},
"process-nextick-args": {
......@@ -243,7 +243,7 @@
"resolved": "https://registry.npmjs.org/promise/-/promise-8.0.1.tgz",
"integrity": "sha1-5F1osAoXZHttpxG/he1u1HII9FA=",
"requires": {
"asap": "~2.0.3"
"asap": "2.0.6"
}
},
"qs": {
......@@ -256,13 +256,13 @@
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
"integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
"requires": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.3",
"isarray": "~1.0.0",
"process-nextick-args": "~2.0.0",
"safe-buffer": "~5.1.1",
"string_decoder": "~1.1.1",
"util-deprecate": "~1.0.1"
"core-util-is": "1.0.2",
"inherits": "2.0.3",
"isarray": "1.0.0",
"process-nextick-args": "2.0.0",
"safe-buffer": "5.1.2",
"string_decoder": "1.1.1",
"util-deprecate": "1.0.2"
}
},
"readline": {
......@@ -275,7 +275,7 @@
"resolved": "https://registry.npmjs.org/rest/-/rest-1.3.2.tgz",
"integrity": "sha1-BBm2ShQ0xy+bFYBK3MnTUFkkcHs=",
"requires": {
"when": "~3"
"when": "3.7.8"
}
},
"safe-buffer": {
......@@ -288,7 +288,7 @@
"resolved": "https://registry.npmjs.org/stream/-/stream-0.0.2.tgz",
"integrity": "sha1-f1Nj8Ff2WSxVlfALyAon9c7B8O8=",
"requires": {
"emitter-component": "^1.1.1"
"emitter-component": "1.1.1"
}
},
"string_decoder": {
......@@ -296,7 +296,7 @@
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
"requires": {
"safe-buffer": "~5.1.0"
"safe-buffer": "5.1.2"
}
},
"sync-request": {
......@@ -304,9 +304,9 @@
"resolved": "https://registry.npmjs.org/sync-request/-/sync-request-6.0.0.tgz",
"integrity": "sha512-jGNIAlCi9iU4X3Dm4oQnNQshDD3h0/1A7r79LyqjbjUnj69sX6mShAXlhRXgImsfVKtTcnra1jfzabdZvp+Lmw==",
"requires": {
"http-response-object": "^3.0.1",
"sync-rpc": "^1.2.1",
"then-request": "^6.0.0"
"http-response-object": "3.0.1",
"sync-rpc": "1.3.4",
"then-request": "6.0.0"
}
},
"sync-rpc": {
......@@ -314,7 +314,7 @@
"resolved": "https://registry.npmjs.org/sync-rpc/-/sync-rpc-1.3.4.tgz",
"integrity": "sha512-Iug+t1ICVFenUcTnDu8WXFnT+k8IVoLKGh8VA3eXUtl2Rt9SjKX3YEv33OenABqpTPL9QEaHv1+CNn2LK8vMow==",
"requires": {
"get-port": "^3.1.0"
"get-port": "3.2.0"
}
},
"then-request": {
......@@ -322,17 +322,17 @@
"resolved": "https://registry.npmjs.org/then-request/-/then-request-6.0.0.tgz",
"integrity": "sha512-xA+7uEMc+jsQIoyySJ93Ad08Kuqnik7u6jLS5hR91Z3smAoCfL3M8/MqMlobAa9gzBfO9pA88A/AntfepkkMJQ==",
"requires": {
"@types/concat-stream": "^1.6.0",
"@types/concat-stream": "1.6.0",
"@types/form-data": "0.0.33",
"@types/node": "^8.0.0",
"@types/qs": "^6.2.31",
"caseless": "~0.12.0",
"concat-stream": "^1.6.0",
"form-data": "^2.2.0",
"http-basic": "^7.0.0",
"http-response-object": "^3.0.1",
"promise": "^8.0.0",
"qs": "^6.4.0"
"@types/node": "8.10.19",
"@types/qs": "6.5.1",
"caseless": "0.12.0",
"concat-stream": "1.6.2",
"form-data": "2.3.2",
"http-basic": "7.0.0",
"http-response-object": "3.0.1",
"promise": "8.0.1",
"qs": "6.5.2"
},
"dependencies": {
"@types/node": {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment