PUT _scripts/networkUtilizationByNwIdAndOrgId03072023search-template { "script": { "lang": "mustache", "source": { "_source": { "includes": [ "identity_id" ] }, "query": { "bool": { "must": [ { "match_phrase": { "network_id": "{{network_id_query_string}}" } }, { "match_phrase": { "organizationId": "{{organizationId_query_string}}" } } ] } }, "aggs": { "date_buckets": { "date_histogram": { "field": "timestamp", "interval": "10m", "time_zone": "UTC", "min_doc_count": 1 }, "aggs": { "unique_identities": { "cardinality": { "field": "identity_id.keyword" } } } } } } } } POST ncutilization-*/_search/template { "id": "networkUtilizationByNwIdAndOrgId03072023search-template", "params": { "network_id_query_string": "d1e8ace1-ab88-4759-92e3-27e2de05294c", "organizationId_query_string": "835c13d6-1208-4242-98c5-c9777032b30a" } } GET _cat/indices?v GET ncutilization.*/_search POST ncutilization-*/_search { "query": { "match_all":{ } } } #### PUT _scripts/networkUtilizationByNwIdAndOrgId03072023search-template { "script": { "lang": "mustache", "source": { "_source": { "includes": [ "identity_id.keyword" ] }, "query": { "bool": { "must": [ { "range": { "timestamp": { "gte": "now-24h", "lte": "now", "format": "epoch_millis" } } }, { "match_phrase": { "network_id.keyword": "{{network_id_query_string}}" } }, { "match_phrase": { "organizationId.keyword": "{{organizationId_query_string}}" } } ] } }, "aggs": { "date_buckets": { "date_histogram": { "field": "timestamp", "interval": "10m", "time_zone": "UTC", "min_doc_count": 1 }, "aggs": { "unique_identities": { "cardinality": { "field": "identity_id.keyword" } } } } } } } } GET ncutilization-*/_search/template { "id": "networkUtilizationByNwIdAndOrgId03072023search-template", "params": { "network_id_query_string": "eea341a7-2457-41ba-95f7-154bce62320a", "organizationId_query_string": "3c9483de-f9bf-4cc1-bfa1-f95eadc78714" } } GET _cat/indices?v