owl-cli 5.28.0 → 5.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -193,6 +193,13 @@ var spec = @spec;
193
193
 
194
194
  var objs = hits.map(function(hit){return hit._source});
195
195
 
196
+
197
+ var countUrl = elasticSearchUrl+"/@projectCode/_count";
198
+
199
+ var ss = HttpUtils.postRaw( countUrl, sndTxt, headers);
200
+ var cr = JSON.parse(ss);
201
+
202
+ var count = result.count;
196
203
  //这里重新从pigeon取了一次数据,做了删除的判断
197
204
  // var ids = hits.map(function(hit){return hit._source.id});
198
205
  // var list = @projectCodeService.getObjects(ids);
@@ -202,7 +209,8 @@ var spec = @spec;
202
209
  var ret = {
203
210
  state:'ok',
204
211
  list:objs,
205
- total:total
212
+ total:total,
213
+ count : count
206
214
  }
207
215
  out.print(JSON.stringify(ret));
208
216
 
@@ -871,8 +871,8 @@ var @projectCodeService = (function (pigeon) {
871
871
  }
872
872
  return filters;
873
873
  },
874
- search: function(m, searchArgs, keyword,from, pageSize, sort, dataSource){
875
- //生成filters
874
+
875
+ buildQuery(m,searchArgs,keyword){
876
876
  delete searchArgs.keyword;
877
877
  var filters = [];
878
878
  for(var k in searchArgs){
@@ -880,14 +880,14 @@ var @projectCodeService = (function (pigeon) {
880
880
  if(typeof v === 'object' && v.type === 'or'){
881
881
  var shouldClauses = [];
882
882
  if(Array.isArray(v.args)){
883
- v.args.forEach(function(q){
884
- var shouldQueries = f.createQuery(q);
885
- if(shouldQueries.length>0){
886
- shouldClauses.push({bool:{filter:shouldQueries}});
887
- }
888
-
889
- });
890
- filters.push({bool:{should:shouldClauses}});
883
+ v.args.forEach(function(q){
884
+ var shouldQueries = f.createQuery(q);
885
+ if(shouldQueries.length>0){
886
+ shouldClauses.push({bool:{filter:shouldQueries}});
887
+ }
888
+
889
+ });
890
+ filters.push({bool:{should:shouldClauses}});
891
891
  }
892
892
  else{
893
893
  if(v.args && typeof(v.args)==='object'){
@@ -945,12 +945,6 @@ var @projectCodeService = (function (pigeon) {
945
945
  else{
946
946
  keywordQuery = "*"
947
947
  }
948
-
949
- var effectiveSort = [{owl_createTime:{order:"desc"}}];
950
- if(sort){
951
- effectiveSort = sort;
952
- }
953
-
954
948
  var query = {
955
949
  "query": {
956
950
  "bool": {
@@ -966,10 +960,47 @@ var @projectCodeService = (function (pigeon) {
966
960
  },
967
961
  "filter": filters
968
962
  }
969
- },
970
- "from" : from, "size" : pageSize,
971
- sort:effectiveSort
963
+ }
964
+ }
965
+ return query;
966
+ },
967
+ count(m,searchArgs,keyword,dataSource){
968
+ var query = f.buildQuery(m,searchArgs,keyword);
969
+ var elasticSearchUrl = $.getEnv( "elasticSearchUrl" );
970
+
971
+ var headers = { "Content-Type": "application/json;charset=utf-8" };
972
+ var elasticSearchUser = $.getEnv("elasticSearchUser");
973
+ var elasticSearchPass = $.getEnv("elasticSearchPass");
974
+ if(elasticSearchUser && elasticSearchPass){
975
+ var auth =Base64.encode(elasticSearchUser + ":" + elasticSearchPass);
976
+ var basicAuth = "Basic " + auth;
977
+ headers["Authorization"] = basicAuth;
978
+ }
979
+ var searchUrl = elasticSearchUrl+"/@projectCode/_count";
980
+ if(dataSource){
981
+ searchUrl = elasticSearchUrl + "/" + dataSource + "/_count";
982
+ }
983
+
984
+ var sndTxt = JSON.stringify(query);
985
+ var s = HttpUtils.postRaw( searchUrl, sndTxt, headers);
986
+ var result = JSON.parse(s);
987
+ if(result.count){
988
+ return result.count;
989
+ }
990
+ return 0;
991
+ },
992
+ search: function(m, searchArgs, keyword,from, pageSize, sort, dataSource){
993
+ var query = f.buildQuery(m,searchArgs,keyword);
994
+ var effectiveSort = [{owl_createTime:{order:"desc"}}];
995
+ if(sort){
996
+ effectiveSort = sort;
997
+ } var effectiveSort = [{owl_createTime:{order:"desc"}}];
998
+ if(sort){
999
+ effectiveSort = sort;
972
1000
  }
1001
+ query.from = from;
1002
+ query.size = pageSize;
1003
+ query.sort = effectiveSort;
973
1004
 
974
1005
  var elasticSearchUrl = $.getEnv( "elasticSearchUrl" );
975
1006
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "owl-cli",
3
- "version": "5.28.0",
3
+ "version": "5.29.0",
4
4
  "main": "index.js",
5
5
  "preferGlobal": true,
6
6
  "bin": {