Skip to content

Commit e4c40bb

Browse files
committed
chore: DocListReadModel에 조회/정렬 조건에 맞춘 compound index 추가
1 parent 41819f4 commit e4c40bb

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

src/main/java/io/ejangs/docsa/domain/doc/readmodel/document/DocListReadModel.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,28 @@
1010
import lombok.Getter;
1111
import lombok.NoArgsConstructor;
1212
import org.springframework.data.annotation.Id;
13-
import org.springframework.data.mongodb.core.index.Indexed;
13+
import org.springframework.data.mongodb.core.index.CompoundIndex;
14+
import org.springframework.data.mongodb.core.index.CompoundIndexes;
1415
import org.springframework.data.mongodb.core.mapping.Document;
1516

1617
@Document("doc_list_read_models")
18+
@CompoundIndexes({
19+
@CompoundIndex(
20+
name = "idx_doc_list_user_deleted_updated",
21+
def = "{'userId': 1, 'deleted': 1, 'updatedAt': -1}"
22+
),
23+
@CompoundIndex(
24+
name = "idx_doc_list_user_deleted_title",
25+
def = "{'userId': 1, 'deleted': 1, 'title': 1}"
26+
)
27+
})
1728
@Getter
1829
@NoArgsConstructor(access = AccessLevel.PROTECTED)
1930
public class DocListReadModel {
2031

2132
@Id
2233
private Long id; // docId
2334

24-
@Indexed
2535
private Long userId;
2636

2737
private String title;

src/main/resources/application.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ spring:
55
data:
66
mongodb:
77
uri: ${SPRING_DATA_MONGODB_URI:${MONGO_URI}}
8+
auto-index-creation: ${SPRING_DATA_MONGODB_AUTO_INDEX_CREATION:true}
89

910
mail:
1011
connection-timeout: 5000

0 commit comments

Comments
 (0)