i wanna use aggs and script in es 6.3 like below
GET /trxdetail-sdall/_search?pretty
 
but the result is
"caused_by": {
 
my setting in elasticsearch.yml is
script.allowed_types: inline
 
my question is how to set the config for using script in aggs? or there is no ways in using script for aggs?
             
            
              
            
           
          
            
            
              Try This
{
  "aggs": {
    "distinct_OPPNAME": {
      "terms": {
        "script": "doc['OPPACC'].value + ' ' + doc['OPPNAME'].value"
      }
    }
  },
  "query": {
    "terms": {
      "OPPACC.keyword": [
        "629005281011"
      ]
    }
  }
}
 
            
              
            
           
          
            
            
              
thanks for reply。 i try it but the same result
"caused_by": {
 
i think mybe it is the setting problem in elasticsearch.yml?
             
            
              
            
           
          
            
              
                rjernst  
              
                  
                    August 30, 2018,  3:27pm
                   
                  4 
               
             
            
              There should be a full stack trace in your logs. Can you add that here?
             
            
              
            
           
          
            
              
                rjernst  
              
                  
                    August 30, 2018,  3:29pm
                   
                  5 
               
             
            
              Also, you explicitly have only search and update scripts allowed in your elasticsearch.yml. You need to add aggs there if you want to do terms aggregations:
script.allowed_contexts: search, update, aggs
 
            
              
            
           
          
            
              
                kennymarx0  
              
                  
                    September 2, 2018, 11:25am
                   
                  6 
               
             
            
              thanks for reply.
my setting is
script.allowed_types: inline
 
and used the script like below, then success! thanks alot .
GET /trxdetail-sdall/_search?pretty
 
             
            
              
            
           
          
            
              
                system  
              
                  
                    September 30, 2018, 11:25am
                   
                  7 
               
             
            
              This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.