首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >查询Depth路径深度

查询Depth路径深度
EN

Stack Overflow用户
提问于 2013-12-16 21:23:11
回答 1查看 552关注 0票数 3

我有一个包含DocumentValue列表的实体文档

代码语言:javascript
复制
@QueryEntity
@Document
public class Document{
 private List<DocumentValue> documentValues;
}

DocumentValue还可以包含DocumentValue的列表

代码语言:javascript
复制
@QueryEntity
public class DocumentValue {
String value;
String name;
String id;
List<DocumentValue> documentValues;
}

我现在正在尝试做一些像这样的事情

代码语言:javascript
复制
private QDocumentValue getDocumentValuePathByDepth(int depth){
               ListPath path = QDocument.document.documentValues;
               if (depth != null) {
            for (int i = 0; i < depth; i++) {
                path = path.documentValues.any();
            }
        }
}

有没有人知道有没有可能做这么深的eleMatch?

喜欢

代码语言:javascript
复制
ListPath<QDocumentValue> query = getDocumentValuePathByDepth(5);
return query.fieldId.eq(documentFilter.getFieldId()).and(query.value.between(from, to));

该深度中的一个documentValues元素应该同时满足这两个条件

BR D.C.

EN

回答 1

Stack Overflow用户

发布于 2013-12-16 23:43:38

Querydsl Mongodb支持elemMatch,如下所示

代码语言:javascript
复制
QDocumentValue documentValue = QDocumentValue.documentValue;
query.anyEmbedded(document.documentValues, documentValue)
     .on(documentValue.id.eq(documentFilter.getFieldId(),
         documentValue.value.between(from, to));
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20612028

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档