postFilter

fun postFilter(vararg filters: QueryExpression): T

Filter expressions in the post filter will be applied after the aggregations are calculated. Useful for building faceted filtering.

Parameters

filters

that will be appended to the existing post filters.

See also

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 
   // Calculate aggregation for all users but fetch only active
searchQuery
    .aggs(
        "is_active" to TermsAgg(UserDoc.isActive)
    )
    .postFilter(
        UserDoc.isActive.eq(true)
    ) 
   //sampleEnd
}

Clears the existing post filters.