(main subject is changed to companies)
I don't have any budget. I'm student. I wanna try to use Elasticsearch in my education
I'm using Node.JS
JSON example:
"companies" : [{ "title" : "value", "hash" : "UniqueValue", ... "employees" : [ "position" : ["EmployeeName", "EmployeeName", "EmployeeName"], "position" : "EmployeeName", ... "position" : "EmployeeName" ], "key" : "value" }, and so on]
More than 1000 different "position" exists. Every company have about 15 employees.
client.indices.create({
index: "компании",
body: {
"mappings": {
"companies": {
"properties": {
"title": {
"type": "string"
},
"hash": {
"type": "string"
},
...
"employees": {
???
}
}
}
}
}
}, function (error, response) {
var body = GetData();
client.bulk({
body: body
}, function (err, resp) {
res.render('index', {result: 'Indexing Completed!'});
})
});
Questions:
- How can i implement "employees"?
- Since "hash" is unique - already existed values should be replaced with newest. Obviously i can just try to remove object with "hash" from database before add new information, but in my mind i'm not supposed to do that. There will be 5-10 removes every second and i think that this may potentially slow down the database in my case (since i'm just a student and don't have any big budgets for high-performance servers).
PS The main target is search - "employees". In 99% cases only they will be a criteria of query. Search may contain all 15 employees.
PPS What if i have much bigger object? Should i separate it or not? How?
Example:
"companies" : [{ "title" : "value", "hash" : "UniqueValue", ... "employees" : [ "position" : ["EmployeeName", "EmployeeName", "EmployeeName"], "position" : "EmployeeName", "position" : ["key" : [values], "key" : ["key" : [values], "key" : ["key" : [values]]]], ... "position" : "EmployeeName" ], "key" : "value" }, and so on]