Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/367.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Ravendb按值查询顺序_Java_Ravendb - Fatal编程技术网

Java Ravendb按值查询顺序

Java Ravendb按值查询顺序,java,ravendb,Java,Ravendb,我的对象具有字段score和id。我需要从from到from+count,按字段score的降序排列,得到一些这个对象的数量。在每个equals范围内,如果存在对象,我需要在该范围的顶部获取特定值为id的对象 例如: 1. score = 10, id = 5 2. score = 20, id = 6 3. score = 20, id = 7 4. score = 20, id = 8 5. score = 30, id = 9 特定值id=7,from=0,count=2 预期

我的对象具有字段
score
id
。我需要从
from
from+count
,按字段
score
的降序排列,得到一些这个对象的数量。在每个equals范围内,如果存在对象,我需要在该范围的顶部获取特定值为
id
的对象

例如:

 1. score = 10, id = 5
 2. score = 20, id = 6
 3. score = 20, id = 7
 4. score = 20, id = 8
 5. score = 30, id = 9
特定值
id
=7,
from
=0,
count
=2

预期结果:

 1. score = 30, id = 9
 2. score = 20, id = 7  <--- my specific value on top of equal range, where score = 20
1。得分=30,id=9

2.score=20,id=7如果索引中索引了此
id
字段,则可以在查询中添加
大于
的条件,以筛选大于“7”的id

因此,查询将类似于:

final List<SomeClass> players = session.query(SomeClass.class, SomeIndexClass.class)
            .whereGreaterThan("id", 7)
            .orderByDescending("score", OrderingType.LONG)
            .skip(from)
            .take(count)
            .toList();
final List players=session.query(SomeClass.class,SomeIndexClass.class)
.其中大于(“id”,7)
.orderByDescending(“分数”,OrderingType.LONG)
.跳过(从)
.记(数)
.toList();
请参阅文档链接:

id
是文档id吗? 因为这样就不必对它进行索引,只需将“where”条件添加到查询中就可以了。 见:

顺便说一句,查看
在每个示例中,单击“Java”选项卡以查看示例Java代码

final List<SomeClass> players = session.query(SomeClass.class, SomeIndexClass.class)
            .whereGreaterThan("id", 7)
            .orderByDescending("score", OrderingType.LONG)
            .skip(from)
            .take(count)
            .toList();