All Downloads are FREE. Search and download functionalities are using the official Maven repository.

freemarker.analytics.dateHistogram.ftl Maven / Gradle / Ivy

The newest version!
{
  "size": 0,
  "query": {
    "bool": {
      "filter": [
<#if query.terms()?has_content>
        {
          "bool": {
            "should": [
            <#list query.terms() as terms>
              {
                "terms": {
                "${terms.field()}": ["${terms.values()?join("\",\"")}"]
                }
              }
              <#sep>,
            
            ]
          }
        },

<#if query.query()?has_content>
        {
          "query_string": {
            "query": "${query.query().filter()}"
          }
        },

<#if query.root()?has_content>
        {
          "term": {
            "${query.root().field()}": "${query.root().id()}"
          }
        },

        {
          "range": {
            "@timestamp": {
              "from": ${roundedFrom},
              "to": ${roundedTo},
              "include_lower": true,
              "include_upper": true
            }
          }
        }
      ]
    }
  },
  "aggregations": {
    "by_date": {
      "date_histogram": {
        "field": "@timestamp",
<#if useFixedInterval??>
        "fixed_interval": "${query.timeRange().interval().toMillis()}ms",
<#else>
        "interval": "${query.timeRange().interval().toMillis()}ms",

        "min_doc_count": 0,
        "extended_bounds": {
          "min": ${roundedFrom},
          "max": ${roundedTo}
        }
      }
<#if query.aggregations()?has_content>
      ,
      "aggregations": {
  <#list query.aggregations() as aggregation>
    <#switch aggregation.type()>
      <#case "FIELD">
      "by_${aggregation.field()}": {
        "terms": {
          "field": "${aggregation.field()}"
           <#if aggregation.size()?has_content>
           ,
            "size": "${aggregation.size()}"
           
        }
      }
        <#break>
      <#default>
      "${aggregation.type()?lower_case}_${aggregation.field()}": {
        "${aggregation.type()?lower_case}": {
        "field": "${aggregation.field()}"
        }
      }
        <#break>
    
    <#sep>,
  
      }

    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy