我想對我的一個數組做一個統計方面的工作。我希望像如何在elasticsearch中獲得數組的數量/大小
"script" : "doc['myField'].doubleValue
或
"script" : "doc['myField'].count
會工作。我還沒有找到任何數組中的數組方法,我甚至不知道是否訪問腳本中的數組字段實際上給了我數組。
我想對我的一個數組做一個統計方面的工作。我希望像如何在elasticsearch中獲得數組的數量/大小
"script" : "doc['myField'].doubleValue
或
"script" : "doc['myField'].count
會工作。我還沒有找到任何數組中的數組方法,我甚至不知道是否訪問腳本中的數組字段實際上給了我數組。
我可能擁有它。看來我需要計算數組內的一個字段而不是數組本身。這可能只是因爲我所有的都是對象數組。
"script" : "doc['arrayField.objectField'].values.length"
看看這裏:http://stackoverflow.com/questions/12733351/how-do-i-sort-the-search-results-according-to-the-number-of-items-in -elasticsear/12734613#12734613 – javanna 2013-03-15 17:42:14