Skip to content

Commit

Permalink
es: add filter to cql fn
Browse files Browse the repository at this point in the history
  • Loading branch information
fgravin committed Jan 26, 2017
1 parent 79e7edb commit 73cd7c5
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
13 changes: 11 additions & 2 deletions web-ui/src/main/resources/catalog/components/solr/SolrRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,17 @@
}
};

geonetwork.GnSolrRequest.prototype.search_es = function() {
var esParams = this.reqParams;
/**
* Search in ES based on current request params.
*
* @param {Object} override to override es request params.
* @returns {angular.Promise}
*/
geonetwork.GnSolrRequest.prototype.search_es = function(override) {
var esParams = angular.extend({},this.reqParams, override);
return this.$http.post(this.ES_URL, esParams).then(function(response) {
return response.data;
});
};

geonetwork.GnSolrRequest.prototype.search = function(qParams, solrParams) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,35 @@
scope.$destroy();
resetHeatMap();
});


scope.toSqlOgr = function() {
solrObject.pushState();
var state = solrObject.getState();

if(!state.any) {
var where = [];
angular.forEach(state.qParams, function(fObj, fName) {
var clause = [];
angular.forEach(fObj.values, function(v, k) {
clause.push(fName + '=' + k);
});
where.push('(' + clause.join(' OR ') + ')');
});
console.log(where.join(' AND '));
}
else {
solrObject.search_es({
size: scope.count || 10000,
aggs: {}
}).then(function(data) {
var where = data.hits.hits.map(function(res) {
return res._id;
});
console.log(where.join(' OR '));
});
}
};
}
};
}]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ <h5 gn-collapsible="solrObject.geomField.expanded">
<i class="fa fa-eraser"></i>&nbsp;
<span translate>reset</span>
</button>
<button data-gn-click-and-spin="toSqlOgr()"
data-ng-if="isFeaturesIndexed"
class="btn btn-default btn-xs gn-reset-facets">
<i class="fa fa-eraser"></i>&nbsp;
<span translate>SQL</span>
</button>
<div data-ng-show="hmActive"
data-ng-if="isFeaturesIndexed">
<label data-ng-show="map"
Expand Down

0 comments on commit 73cd7c5

Please sign in to comment.