[英]Correct use of @CompoundIndex and MongoRepository
我的查詢響應很慢,所以我想知道我是否正在創建復合 mongo 索引並將其與 MongoRepository 有效地使用,以及如何驗證索引是否有效工作。
@CompoundIndexes({
@CompoundIndex(name = "onwebsite_process_sequence", def = "{'additionalfields.onwebsite': 1, 'additionalfields.process' : 1, 'additionalfields.onwebsite': 1}")
})
public class DdsJson {
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonProperty("additional_fields")
AdditionalFields additionalfields = new AdditionalFields();
...
}
public class AdditionalFields {
public static final Logger LOG = LoggerFactory.getLogger(AdditionalFields.class);
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonProperty("sequence")
@Indexed
private Integer sequence;
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonProperty("process")
@Indexed
private Integer process;
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonProperty("onwebsite")
@Indexed
private String onwebsite;
}
public interface DdsJsonRepository extends MongoRepository<DdsJson, Integer> {
Page<DdsJson> findByAdditionalfields_OnwebsiteAndAdditionalfields_SequenceAndAdditionalfields_Sequence(String onwebsite,int process, int sequence, Pageable pageable);
}
問候康泰
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.