<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # 統計 最后,我們還有一個需求需要完成:可以讓老板在職工目錄中進行統計。Elasticsearch 把這項功能稱作 _匯總 (aggregations)_,通過這個功能,我們可以針對你的數據進行復雜的統計。這個功能有些類似于 SQL 中的 `GROUP BY`,但是要比它更加強大。 例如,讓我們找一下員工中最受歡迎的興趣是什么: ~~~ GET /megacorp/employee/_search { "aggs": { "all_interests": { "terms": { "field": "interests" } } } } ~~~ 請忽略語法,讓我們先來看一下結果: ~~~ { ... "hits": { ... }, "aggregations": { "all_interests": { "buckets": [ { "key": "music","doc_count": 2 }, { "key": "forestry","doc_count": 1}, { "key": "sports","doc_count": 1 } ] } } } ~~~ 我們可以發現有兩個員工喜歡音樂,還有一個喜歡森林,還有一個喜歡運動。這些數據并沒有被預先計算好,它們是在文檔被查詢的同時實時計算得出的。如果你想要查詢姓 Smith 的員工的興趣匯總情況,你就可以執行如下查詢: ~~~ GET /megacorp/employee/_search { "query": { "match": { "last_name": "smith" } }, "aggs": { "all_interests": { "terms": { "field": "interests" } } } } ~~~ 這樣,`all_interests` 的統計結果就只會包含滿足查詢的文檔了: ~~~ ... "all_interests": { "buckets": [ { "key": "music", "doc_count": 2 }, { "key": "sports", "doc_count": 1 } ] } ~~~ 匯總還允許多個層面的統計。比如我們還可以統計每一個興趣下的平均年齡: ~~~ GET /megacorp/employee/_search { "aggs" : { "all_interests" : { "terms" : { "field" : "interests" }, "aggs" : { "avg_age" : { "avg" : { "field" : "age" } } } } } } ~~~ 雖然這次返回的匯總結果變得更加復雜了,但是它依舊很容易理解: ~~~ ... "all_interests": { "buckets": [ { "key": "music", "doc_count": 2, "avg_age": { "value": 28.5 } }, { "key": "forestry", "doc_count": 1, "avg_age": { "value": 35 } }, { "key": "sports", "doc_count": 1, "avg_age": { "value": 25 } } ] } ~~~ 在這個豐富的結果中,我們不但可以看到興趣的統計數據,還能針對不同的興趣來分析喜歡這個興趣的`平均年齡`。 即使你現在還不能很好地理解語法,但是相信你還是能發現,用這個功能來實現如此復雜的統計工作是這樣的簡單。你的極限取決于你存入了什么樣的數據喲!
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看