sort

fun sort(vararg sorts: Sort): T

Adds sorts to the existing query sorting expressions.

Samples

import dev.evo.elasticmagic.SearchQuery
import dev.evo.elasticmagic.aggs.HistogramAgg
import dev.evo.elasticmagic.aggs.TermsAgg
import dev.evo.elasticmagic.doc.Document
import dev.evo.elasticmagic.query.Bool
import dev.evo.elasticmagic.query.FunctionScore
import dev.evo.elasticmagic.query.MatchPhrase
import dev.evo.elasticmagic.query.MultiMatch
import dev.evo.elasticmagic.query.NodeHandle
import dev.evo.elasticmagic.query.QueryExpressionNode
import dev.evo.elasticmagic.query.QueryRescore
import dev.evo.elasticmagic.query.match

import kotlin.random.Random
fun main() { 
   //sampleStart 
   // Sort query by a document score and a user id
searchQuery.sort(UserDoc.runtime.score, UserDoc.id.desc()) 
   //sampleEnd
}

See also


fun sort(sorts: List<Sort>): T

Adds sorts from a list to the existing query sorting expressions.

Samples

import dev.evo.elasticmagic.SearchQuery
import dev.evo.elasticmagic.aggs.HistogramAgg
import dev.evo.elasticmagic.aggs.TermsAgg
import dev.evo.elasticmagic.doc.Document
import dev.evo.elasticmagic.query.Bool
import dev.evo.elasticmagic.query.FunctionScore
import dev.evo.elasticmagic.query.MatchPhrase
import dev.evo.elasticmagic.query.MultiMatch
import dev.evo.elasticmagic.query.NodeHandle
import dev.evo.elasticmagic.query.QueryExpressionNode
import dev.evo.elasticmagic.query.QueryRescore
import dev.evo.elasticmagic.query.match

import kotlin.random.Random
fun main() { 
   //sampleStart 
   // Sort query by a document score and a user id
searchQuery.sort(UserDoc.runtime.score, UserDoc.id.desc()) 
   //sampleEnd
}

See also


fun sort(clear: SearchQuery.CLEAR): T

Clears the existing sorts.