Invalid aggregation order path [something]. Buckets can only be sorted on a sub-aggregator path that is built out of zero or more single-bucket aggregations within the path and a final single-bucket or a metrics aggregation at the path end.



아래와 같은 샘플을 만들었었다.



"query" : {

   ... 검색 조건...

}.

"aggs" : {

"term_key" : {

"terms": {

"field" : "field_first",

"order" : {

"something" : "desc"

}

}

"aggs": {

"something" : {

"terms":{

"field":"field_second"

},

"aggs" : {

"sumofgold" : {

"sum": {

"field":"gold"

}

}

}

}

}

}

}


something과 sumofgold 둘 다 정렬을 하고 싶었는데 그건 안된다. path의 마지막에 오는 metrics aggregation 혹은 단일 버킷으로만 정렬 가능하다.


결과 받아서 코드로 정렬 시켜 해결함.


자주 사용하는 기능들 모아서 정리한 코드입니다. 


필요하신 분들은 가져다 그대로 사용하시면 됩니다. 



Date.prototype.mmddyyyy = function() {

      return (this.getMonth() + 1) +

      "/" +  this.padZero(this.getDate()) +

      "/" +  this.padZero(this.getFullYear());

};

Date.prototype.yyyymmdd = function() {

      return this.getFullYear()  +

      "/" +  this.padZero((this.getMonth() + 1)) +

      "/" +  this.padZero(this.getDate());

};

Date.prototype.mmddyyyytime = function(){

      return (this.getMonth() + 1) +

      "/" +  this.padZero(this.getDate()) +

      "/" +  this.padZero(this.getFullYear()) +

      " " + this.padZero(this.getHours()) + 

      ":" + this.padZero(this.getMinutes()) + 

      ":" + this.padZero(this.getSeconds());

};


Date.prototype.yyyymmddfordb = function() {

   var yyyy = this.getFullYear();

   var mm = this.getMonth() < 9 ? "0" + (this.getMonth() + 1) : (this.getMonth() + 1); // getMonth() is zero-based

   var dd  = this.getDate() < 10 ? "0" + this.getDate() : this.getDate();

   return "".concat(yyyy).concat("-").concat(mm).concat("-").concat(dd);

};


Date.prototype.yyyymmddtime = function(){

      return this.getFullYear()  +

      "/" +  this.padZero((this.getMonth() + 1)) +

      "/" +  this.padZero(this.getDate())+

      " " + this.padZero(this.getHours()) + 

      ":" + this.padZero(this.getMinutes()) + 

      ":" + this.padZero(this.getSeconds());

};

Date.prototype.yyyymmddstarttime = function(){

      return this.getFullYear()  +

      "/" +  this.padZero((this.getMonth() + 1)) +

      "/" +  this.padZero(this.getDate())+

      " " + "00:00:00";

};

Date.prototype.yyyymmddendtime = function(){

      return this.getFullYear()  +

      "/" +  this.padZero((this.getMonth() + 1)) +

      "/" +  this.padZero(this.getDate())+

      " " + "23:59:59";

};

Date.prototype.padZero =function (n) {

      n = n + '';

      return n.length >= 2 ? n : new Array(2 - n.length + 1).join('0') + n;

}



var util_date = {

      getToday_yyyymmdd: function(){

      var today = new Date();

      return today.yyyymmdd();

      },

      get_yyyymmdd:function(_date){

            if( _date == "" || _date == null || _date == undefined ){

                  return null;

            }else{

                  var date = new Date(_date);

                  return date.yyyymmdd();

            }

      },

      getToday_yyyymmddtime:function(_date){

            if( _date == "" || _date == null || _date == undefined ){

                  return null;

            }else{

                  var date = new Date(_date);

                  return date.yyyymmddtime();

            }

      },

      get_yyyymmddtime:function(_date){

            if( _date == "" || _date == null || _date == undefined ){

                  return null;

            }else{

                  var date = new Date(_date);

                  return date.yyyymmddtime();

            }

      },

      getThisMonday: function(_date){

            var d = new Date(_date);

            var day = d.getDay(),

            diff = d.getDate() - day + (day == 0 ? -6:1); // adjust when day is sunday

            return new Date(d.setDate(diff));

      },

      getLastMonday: function(_date){

            var d = this.getThisMonday(_date);

            return this.getNextDay(d,-7);

      },

      getNextMonday: function(_date){

            var d = this.getThisMonday(_date);

            return this.getNextDay(d,7);

      },

      getNextDay: function(_date, _count){

            var d = new Date(_date);

            d.setDate(d.getDate() + _count);

            return new Date(d);

      },

      getMonday:function(d, weeksago) {

            var day = d.getDay(),

            diff = d.getDate() - day + (day == 0 ? -6:1); // adjust when day is sunday

            var monday = new Date(d.setDate(diff));

            monday.setDate( monday.getDate()- 7*weeksago);


            return monday;

      },

      getFirstday: function(d){

            var t = new Date(d);

            return new Date(t.getFullYear(), t.getMonth(), 1);

      },

      getFirstdayOfLastMonth: function(d){

            var t = this.getLastdayOfLastMonth(d,0);

            return new Date(t.getFullYear(), t.getMonth(), 1);

      },

      getLastdayOfLastMonth: function(d, monthsago){

            var t = new Date(d);

            t.setMonth( t.getMonth()-monthsago);

            t = new Date(t.getFullYear(), t.getMonth(), 0);


            return t;

      },

      getLastdayOfThisMonth:function(d){

            var t = new Date(d);

            return new Date(t.getFullYear(), t.getMonth() + 1, 0);

      },

      getFirstdayOfNextMonth: function(d){

            var t = this.getLastdayOfThisMonth(d);

            return this.getNextDay(t, 1);

      },

      getDiffDays: function(f , s){

            var date1 = new Date(f);

            var date2 = new Date(s);

            var timediff = Math.abs( date1.getTime() - date2.getTime() );

            return Math.ceil( timediff/(1000*3600*24));

      },

      bThisMonth: function ( d ){

            var today = new Date();

            var date1 = new Date(d);

            if(today.getFullYear() == date1.getFullYear() && today.getMonth() == date1.getMonth())

                  return true;


            return false;

      },

      bToday: function ( d ){

            var today = new Date();

            var date1 = new Date(d);

            if(today.getFullYear() == date1.getFullYear() && today.getMonth() == date1.getMonth() && today.getDay() == date1.getDay())

                  return true;


            return false;

      },

      bThesedays: function(d){

            var today = new Date();

            var date1 = new Date(d);


            var diff = this.getDiffDays( today, date1);

            if(diff < 5)

                  return true;


            return false;

      }

};


module.exports = util_date;


[about setting command line tools ]


react-native run-ios 로 실행을 시도했을 때 command line tools 없다는 에러가 발생하는데, 


xcode-select --install로 설치를 해도 반응이 없다. 


단순히 설치만 해서는 안되고 xcode preferences에 설정을 해야 한다. 


XCode > Preferences > Locations 화면에서 Command Line Tools 이 비어 있다면 이를 설정하면 된다.

--------------------------------------------------------------------------------------------------------

when it occurs an error there is no command line tools you run "react-native run-ios" command


in my case, it doesn't work even I installed the tool like this "xcode-select --install"


the reason is ... you have to set an information in XCode > Preferences > Locations.





[8081 port problem]


sudo lsof -i :8081 로 해당 프로세스 찾아서 kill.

--------------------------------------------------------------------------------------------------------

Find a process using the port 8081 like this " sudo lsof -i : 8081" and kill it.



[Build failed]

Entry, ":CFBundleIdentifier", Does Not Exist


signing 관련 이슈. 생성한 프로젝트의 xcodeproj 로 xcode 실행 후 General > Signing 설정. 이후 빌드하면 관련 에러없이 애뮬레이터로 실행됨.--------------------------------------------------------------------------------------------------------

The reason is about signing. You have to set a signing information in XCode project > General/Signing on XCode project that you made.



[error : npm update check failed]


sudo chown -R $USER:$(id -gn $USER) /Users/YOUR_USERNAME_HERE/.config





+ Recent posts