Elastic Schema for frequently update


(Saeed Moqadam) #1

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 counts.

Now I have two questions,

  1. what is the problem with the first solution?
  2. how can I change the schema if I want to update counts in orders and products array?

(system) #2

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.