I'm trying to implement CQRS architecture in Microservices style, what I've decided is to use elastic search and READ and Postgresql as our WRITE database.
By the assumption that we have 3 microservices and every microservice has 1 database
user table
id | name | age
----+----------+------
1 | Robert | 30
2 | Jessica | 40
3 | Jennifer | 50
4 | Jack | 600
event
id | user_id | event_name
----+---------+------
1 | 3 | python
2 | 4 | elasticsearch
3 | 2 | postgres
4 | 2 | cqrs
finantial
id | user_id | cash
----+---------+------
1 | 1 | 30
2 | 2 | 40
3 | 3 | 50
4 | 4 | 600
I don't know,but I think the structure below for elasticsearch is good
PUT test
{
"mappings": {
"properties": {
"name": {
"type": "text"
},
"age":{
"type": "integer"
},
"events": {
"type": "nested"
},
"cash": {
"type": "integer"
}
}
}
}
Now what is the best practice to implement data structure in elasticsearch index ?