-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
51 lines (44 loc) · 1.45 KB
/
index.js
File metadata and controls
51 lines (44 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
var fs = require('fs');
var elasticsearch = require('elasticsearch');
var path = './Data/';
var file = fs.readdirSync(path);
var count = 0;
var client = new elasticsearch.Client({
host:'localhost:9200',
log:'trace'
});
for (var i = 0; i < file.length;i++) {
var reading = JSON.parse(fs.readFileSync(path+file[i]));
//console.log(reading);
for (var j = 0; j < reading.items.length; j++) {
count++;
client.index({
index:'bd',
type:'user',
id:count,
body:{
salary: reading.items[j].salary,
snippet: reading.items[j].snippet,
archived: reading.items[j].archived,
premium: reading.items[j].premium,
name: reading.items[j].name,
area: reading.items[j].area,
url: reading.items[j].url,
created_at: reading.items[j].created_at,
apply_alternate_url: reading.items[j].apply_alternate_url,
relations: reading.items[j].relations,
employer: reading.items[j].employer,
response_letter_required: reading.items[j].response_letter_required,
published_at: reading.items[j].published_at,
address: reading.items[j].address,
department: reading.items[j].department,
alternate_url: reading.items[j].alternate_url,
type: reading.items[j].type,
id: reading.items[j].id
}
}, function(err,res) {
console.log(err);
console.log(res);
});
}
}