import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey' ; export interface MustCondition { bool : Pick < estypes . QueryDslBoolQuery , 'must' > ; } export interface MustNotCondition { bool : Pick < estypes . QueryDslBoolQuery , 'must_not' > ; } export interface ScriptBasedSortClause { _script : { type : string ; order : string ; script : ScriptClause ; } ; } export interface ScriptClause { source : string ; lang : estypes . ScriptLanguage ; params ? : { [ field ] : string | number | Date | string [ ] | { [ field ] : string | number | Date ; } ; } ; } export type PinnedQuery = Pick < estypes . QueryDslQueryContainer , 'pinned' > ; type BoolClause = Pick < estypes . QueryDslQueryContainer , 'bool' > ; export function matchesClauses ( ... clauses ) { return { bool : Object . assign ( { } , ... clauses . map ( ( clause ) => clause . bool ) ) , } ; } export function shouldBeOneOf ( ... should ) { return { bool : { should , } , } ; } export function mustBeAllOf ( ... must ) { return { bool : { must , } , } ; } export function filterDownBy ( ... filter ) { return { bool : { filter , } , } ; } export function asPinnedQuery ( ids , organic ) { return { pinned : { ids , organic , } , } ; }