import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey' ; import { SERVICE_ENVIRONMENT , SERVICE_NODE_NAME , } from '../elasticsearch_fieldnames' ; import { ENVIRONMENT_ALL , ENVIRONMENT_NOT_DEFINED , } from '../environment_filter_values' ; import { SERVICE_NODE_NAME_MISSING } from '../service_nodes' ; export function environmentQuery ( environment ) { if ( ! environment || environment === ENVIRONMENT_ALL . value ) { return [ ] ; } if ( environment === ENVIRONMENT_NOT_DEFINED . value ) { return [ { bool : { must_not : { exists : { field : SERVICE_ENVIRONMENT } } } } ] ; } return [ { term : { [ SERVICE_ENVIRONMENT ] : environment } } ] ; } export function serviceNodeNameQuery ( serviceNodeName ? ) { if ( ! serviceNodeName ) { return [ ] ; } if ( serviceNodeName === SERVICE_NODE_NAME_MISSING ) { return [ { bool : { must_not : [ { exists : { field : SERVICE_NODE_NAME } } ] } } ] ; } return [ { term : { [ SERVICE_NODE_NAME ] : serviceNodeName } } ] ; }