filter

fun filter(vararg filters: QueryExpression): T

Combines all the filter expressions together and wraps the existing query using the dev.evo.elasticmagic.query.Bool query expression.

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 
   searchQuery.filter(
    UserDoc.isActive.eq(true),
    Bool.should(
        UserDoc.isActive.eq(false),
        UserDoc.name.match("system"),
    )
) 
   //sampleEnd
}

See also

Parameters

filters

query filters which will be appended to the existing filters.


fun filter(filters: List<QueryExpression>): T


Clears the existing filters.