ElasticSearch: Nested Arrays vs Separate Types -


I am using elastic search as a data store and I think about structuring my data My natural tendency from MySQL is to divide everything into different types ("tables"), but I'm sure if anything is achieved for it. For example, I have an article with comments in it and I want to keep track of the users who have clicked "like" on the comment, should I just keep the array of User ID in the nested array inside the article's comments, Or should I take steps to type a comment separately? And the comments about the array of those users, should it also be of a different type?

  {"article": {"properties": {... "comments": {"property": {... "likes": {"type": "string"} // UIID}}}   

Is there a problem with nested array being nested array from an efficiency perspective? And it is better to use nested searches as a data store to use nested arrays / objects or different types?

This is a widespread question, and the general answer is "it depends" I would say that your data When planning the structure you need to consider two main things.

One is your access pattern - what types of searches do you need, and what kind of aggregation (if any) you want on your data, try to map your uses that you Can achieve with the structure you have created.

The second is the updated pattern, this is sometimes ignored in favor of the access pattern, but it is worth noting on important values. For example, if there is not much change in the article, but there may be a lot of comments in it - you may have to perform better comments in the form of separate documents (and types), because you can write your comments on each comment No need to re-write. (Remember that updating a document in Alicashaskar is actually re-indexed.)

I recommend watching this article - and familiar with the difference between nested objects and parent-child types After being (better later when you have different update patterns for parents and baby).

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -