java - 正确使用@CompoundIndex 和 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);
}
问候康泰
解决方案
推荐阅读
- javascript - 当我从映射数组中单击相应的 TouchableOpacity 时获取键值
- r - ggplot 的颜色面板有两种颜色。获取用于为 geom_rect 着色的面板的 bbox
- typescript - 如何使用 typescript 指定 axios promise 中捕获的错误?
- python - SqlAlchemy 为每个新组合自动增加复合键
- python-3.x - 获取与数字的一维热图对应的颜色
- kubernetes - 从 prometheus 中的不同 pod 收集指标
- laravel - Laravel 8:POST 请求被视为 GET
- flutter - Flutter Web - 直接从 Web 应用程序发送邮件
- azure - 服务主体或托管标识
- excel - 在 Xpath 语法中使用字符串变量