ES Main concepts of data architecture and relational database Mysql contrast
Here is a picture description
(1) Database in relational database (DataBase), Equivalent to ES Index in (Index)
(2) Under a database, there are N Table (Table), Equivalent to 1 Indexes Index There are N Multi type (Type),
(3) A database table (Table) The data under the (ROW) Multi column (column, attribute ) form , Equivalent to 1 individual Type By multiple documents (Document) He Duo Field form .
(4) In a relational database ,schema The table is defined , Fields for each table , There is also the relationship between tables and fields .
Corresponding , stay ES in :Mapping Define the Type Field processing rules for , That is, how to establish the index , Index type , Do you want to save the original index JSON file , Is the original compressed JSON file , Do we need word segmentation , How to deal with word segmentation .
(5) Add in database insert, Delete delete, change update, check search The operation is equivalent to ES Increase in PUT/POST, Delete Delete, change _update, check GET.
ES Application scenarios of
Usually we have two problems :
1) Try to use the new system development ES As a storage and retrieval server ;
2) The existing system upgrade needs to support full-text retrieval service , Need to use ES.
ES Not a database , It is suitable for massive data , Data with low update frequency (ES There is no transaction and it is not suitable for processing parallel change data ).
ES It is more suitable to deal with data with relatively simple and stable relationship , Some data with complex relationships are used mysql Such a relational database uses sql It's easy to implement , however es It's quite complicated .
I'm trying to record millions of data in two databases involving two tables : I hope to do further analysis on the application of the two databases from the perspective of implementation and performance through some more specific demand scenarios .
Multi field query and two table associated query
ES It supports multi condition filtering and query for multiple fields in the same table at the same time . There's nothing to say about that .
For two table queries, for example :
Table1:
classID className
1 Class name
Table2:
stuID classID stuName
1 class ID Student name
I want to check 1 The names of all the students in the class . This is very important for mysql It's very easy to implement .
about ES It can be used “ Nested objects Nested”. From the data structure, it is in the following form json object
{
stuID: 1,
stuName: Liu Ming ,
classInfo: // If a student is only in one class, this object array is not needed. Here is just to illustrate the implementation
[ {
classID: 1,
className: Magic class
},
{
classID: 2,
className: Science and technology class
}
......
]
},
........
Technology