Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

114
Vistas
Ravendb query order by value

I have objects with fields score and id. I need to get some amount of this objecs from from to from + count, which ordering by field score in descending order. Inside each equals range I need to get object with specific value of id on top of this range if it exist.

Example:

 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

Specific value id = 7, from = 0, count = 2

Expected result:

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

I write simple query:

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

But this does not take into account the conditions with specific value id. How can i do it?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

If you have this id field indexed in your index, then you can add a whereGreaterThan condition in your query, to filter for those id's that are greater than '7'

So query would be something like:

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

See documentation link:
https://ravendb.net/docs/article-page/5.1/java/indexes/querying/filtering#where---numeric-property

Is id the document id ? because then it doesn't have to be indexed, should work w/ just adding the 'where' condition to the query. See: https://ravendb.net/docs/article-page/5.1/java/indexes/querying/basics#example-ii---filtering

Btw, check out the code samples in https://demo.ravendb.net/
In each sample, click the 'Java' tab to see sample Java code.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda