I'm new to elastic and need to know what is the best schema design for an index that need to update frequently. My schema is like this:
{
"_index" : "test_index",
"_type" : "test_type",
"_id" : "10000",
"_score" : 1.0,
"_source" : {
"user_id" : 12,
"index_date" : {
"date" : "2018-02-06 14:25:49.816952",
"timezone_type" : 3,
"timezone" : "UTC"
},
"rating" : null,
"orders" : [
{
"hour" : "08",
"v_id":100,
"count" : 1
},
{
"hour" : "10",
"v_id":100,
"count" : 1
}
],
"products" : [
{
"p_id" : 970111,
"count" : 4
},
{
"p_id" : 1280811,
"count" : 1
},
]
}
},
but if I want to update count
in orders
array I have two options:
1. find the index, update, reindex
- I have to find the index
- then update count in my programming language(PHP)
- then reindex the whole object
2. change the schema
I think the first solution is not the proper way to work with elastic(in this case) and I believe my schema need to change if I want to update count
s.
Now I have two questions,
- what is the problem with the first solution?
- how can I change the schema if I want to update
count
s inorders
andproducts
array?