2017-01-29 5 views
1

ES 2.4.0
インラインスクリプトとストアドスクリプトの両方で集計を試みました。私は上記のコードを実行すると、私は..ESで1つのクエリでインラインスクリプトとストアドスクリプトの両方を実行できますか?

{ 
     "size": 0, 
     "aggregations": { 
     "dayOfWeek": { 
      "terms": { 
      "script": "doc['created_at'].date.dayOfWeek().getAsText()" 
      }, 
      "aggs": { 
      "byHours": { 
       "terms": { 
       "order": { 
        "_term": "asc" 
       }, 
       "script": "test", 
       "params": { 
        "date_field": "created_at", 
        "format": "HH" 
       } 
       } 
      } 
      } 
     } 
     } 
    } 

を、それがエラーを示しているコードを実行したときしかし、私はあなたがこのようにスクリプトファイルを参照する必要がこれらの

{ 
    "took": 106, 
    "timed_out": false, 
    "_shards": { 
    "total": 5, 
    "successful": 1, 
    "failed": 4, 
    "failures": [ 
     { 
     "shard": 1, 
     "index": "test", 
     "node": "PHgQhqS8T6KORwsJ5ChzHg", 
     "reason": { 
      "type": "script_exception", 
      "reason": "failed to run inline script [test] using lang [groovy]", 
      "caused_by": { 
      "type": "missing_property_exception", 
      "reason": "No such property: test for class: a94a8fe5ccb19ba61c4c0873d391e987982fbbd3" 
      } 
     } 
     } 
    ] 

答えて

1

のようなエラーを取得しています:

{ 
    "size": 0, 
    "aggregations": { 
    "dayOfWeek": { 
     "terms": { 
     "script": "doc['created_at'].date.dayOfWeek().getAsText()" 
     }, 
     "aggs": { 
     "byHours": { 
      "terms": { 
      "order": { 
       "_term": "asc" 
      }, 
      "script": {     <--- modify this section 
       "file": "test", 
       "params": { 
       "date_field": "created_at", 
       "format": "HH" 
       } 
      } 
      } 
     } 
     } 
    } 
    } 
} 
+0

ありがとうございます。あなたはこの質問を解決する際に私を助けてくれますか?http://stackoverflow.com/questions/41912800/viewing-the-documents-on-per-weekday-classification?noredirect=1#comment71017184_41912800 – Seeker

+0

yeah..its良い私はそれを受け入れた – Seeker

関連する問題