我正在努力弄清楚如何使用QueryDSL查询具有String []字段(称为扩展)的mongodb集合。
@Document
public class Recording {
private String from;
private String to;
private Date created;
private String[] extensions;
}
public RecordingPagedRequest {
...
private Predicate toPredicate() {
QRecording recording = QRecording.Recording;
BooleanBuilder booleanBuilder = new BooleanBuilder();
if (!StringUtils.isNullOrEmpty(caller)) {
booleanBuilder.and(recording.from.like("%" + caller + "%"));
}
if (!StringUtils.isNullOrEmpty(called)) {
booleanBuilder.and(recording.to.like("%" + called + "%"));
}
if (!StringUtils.isNullOrEmpty(extension)) {
//What to put here?
//booleanBuilder.and(recording.extensions.?????;
}
if (start != null) {
booleanBuilder.and(recording.created.after(start));
}
if (end != null) {
booleanBuilder.and(recording.created.before(end));
}
return booleanBuilder.getValue();
}
}
理想情况下,我希望能够对扩展String []执行类似的查询。
谢谢。