gpt4 book ai didi

postgresql - 在微服务风格中使用 elasticsearch 实现 CQRS 的最佳实践是什么?

转载 作者:行者123 更新时间:2023-12-05 06:51:46 25 4
gpt4 key购买 nike

<分区>

我正在尝试以微服务风格实现 CQRS 架构,我决定使用 Elasticsearch 和 READ 以及 Postgresql 作为我们的WRITE 数据库。

假设我们有 3 个微服务,每个微服务有 1 个数据库

     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

我不知道,但我认为elasticsearch下面的结构很好

PUT test
{
"mappings": {
"properties": {
"name": {
"type": "text"
},
"age":{
"type": "integer"
},
"events": {
"type": "nested"
},
"cash": {
"type": "integer"
}
}
}

}

现在在 elasticsearch 索引中实现数据结构的最佳实践是什么?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com