This is an automated email from the ASF dual-hosted git repository.
epugh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/main by this push:
new e3c27d4 SOLR-15824 Improved Query Screen raw query parameters section
(#436)
e3c27d4 is described below
commit e3c27d434cec85c67ea03db580648c80d73a9e42
Author: Betul Ince <[email protected]>
AuthorDate: Wed Dec 15 23:12:50 2021 +0300
SOLR-15824 Improved Query Screen raw query parameters section (#436)
* Improved Query Screen fq and raw query parameters sections
---
solr/CHANGES.txt | 4 +-
solr/webapp/web/js/angular/controllers/query.js | 92 ++++++++++++++++---------
solr/webapp/web/partials/query.html | 19 +++--
3 files changed, 74 insertions(+), 41 deletions(-)
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 1da35bd..d0c8ec6 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -178,11 +178,13 @@ when told to. The admin UI now tells it to. (Nazerke
Seidan, David Smiley)
* SOLR-15427: Nested docs: [child limit=...] now defaults to -1 which is
interpreted as unlimited.
(David Smiley)
-
+
* SOLR-15786: Add the "films" example to SolrCLI via -e films parameter. (Eric
Pugh)
* SOLR-15834: Films example readme needs updating, including useParams support
for multiple algorithms. (Eric Pugh)
+* SOLR-15824 Improved Query Screen handling of raw query parameters. (Betul
Ince via Tim Potter, Eric Pugh)
+
Build
---------------------
diff --git a/solr/webapp/web/js/angular/controllers/query.js
b/solr/webapp/web/js/angular/controllers/query.js
index 86958c8..c3475ce 100644
--- a/solr/webapp/web/js/angular/controllers/query.js
+++ b/solr/webapp/web/js/angular/controllers/query.js
@@ -16,11 +16,12 @@
*/
solrAdminApp.controller('QueryController',
- function($scope, $routeParams, $location, Query, Constants){
+ function($scope, $route, $routeParams, $location, Query, Constants){
$scope.resetMenu("query", Constants.IS_COLLECTION_PAGE);
$scope._models = [];
$scope.filters = [{fq:""}];
+ $scope.rawParams = [{rawParam:""}];
$scope.val = {};
$scope.val['q'] = "*:*";
$scope.val['q.op'] = "OR";
@@ -43,8 +44,8 @@ solrAdminApp.controller('QueryController',
if( !urlParams.hasOwnProperty(p) ){
continue;
}
+ // filters and rawParams are handled specially because of possible
multiple values
if( p === "fq" ) {
- // filters are handled specially because of possible multiple
values
addFilters(urlParams[p]);
} else {
setParam(p, urlParams[p]);
@@ -74,12 +75,16 @@ solrAdminApp.controller('QueryController',
}
// store not processed values to be displayed in a field
function insertToRawParams(argKey, argValue){
- if( $scope.rawParams == null ){
- $scope.rawParams = "";
+ if( ($scope.rawParams.length === 0) || ($scope.rawParams.length === 1 &&
$scope.rawParams[0].rawParam === "") ){
+ $scope.rawParams = [];
+ }
+ if (argValue instanceof Array) {
+ for (var index in argValue) {
+ $scope.rawParams.push({rawParam: argKey + "=" + argValue[index]});
+ }
} else {
- $scope.rawParams += "&";
+ $scope.rawParams.push({rawParam: argKey + "=" + argValue});
}
- $scope.rawParams += argKey + "=" + argValue;
}
function addFilters(argObject){
if( argObject ){
@@ -94,7 +99,7 @@ solrAdminApp.controller('QueryController',
}
}
- $scope.doQuery = function() {
+ $scope.doQuery = function(isPageReload) {
var params = {};
var set = function(key, value) {
@@ -140,27 +145,29 @@ solrAdminApp.controller('QueryController',
purgeParams(params, getDependentFields("spatial"), $scope.val.spatial
!== true);
purgeParams(params, getDependentFields("spellcheck"),
$scope.val.spellcheck !== true);
- if ($scope.rawParams) {
- var rawParams = $scope.rawParams.split(/[&\n]/);
- for (var i in rawParams) {
- var param = rawParams[i];
- var equalPos = param.indexOf("=");
- if (equalPos > -1) {
- set(param.substring(0, equalPos), param.substring(equalPos+1));
- } else {
- set(param, ""); // Use empty value for params without "="
- }
- }
- }
-
var qt = $scope.qt ? $scope.qt : "/select";
for (var filter in $scope.filters) {
copy(params, $scope.filters[filter]);
}
+ for (var rawIndex in $scope.rawParams) {
+ if ($scope.rawParams[rawIndex].rawParam) {
+ var rawParam = $scope.rawParams[rawIndex].rawParam.split(/[&\n]/);
+ for (var i in rawParam) {
+ var param = rawParam[i];
+ var equalPos = param.indexOf("=");
+ if (equalPos > -1) {
+ set(param.substring(0, equalPos), param.substring(equalPos+1));
+ } else {
+ set(param, ""); // Use empty value for params without "="
+ }
+ }
+ }
+ }
+
params.core = $routeParams.core;
- if (qt[0] == '/') {
+ if (qt[0] === '/') {
params.handler = qt.substring(1);
} else { // Support legacy style handleSelect=true configs
params.handler = "select";
@@ -176,18 +183,21 @@ solrAdminApp.controller('QueryController',
if( $scope.qt != null ) {
adminParams.qt = [$scope.qt];
}
-
- Query.query(params, function(data) {
- $scope.lang = $scope.val['wt'];
- if ($scope.lang == undefined || $scope.lang == '') {
- $scope.lang = "json";
- }
- $scope.response = data;
- // Use relative URL to make it also work through proxies that may have
a different host/port/context
- $scope.url = url;
- $scope.hostPortContext =
$location.absUrl().substr(0,$location.absUrl().indexOf("#")); // For display
only
+ if (isPageReload) {
+ Query.query(params, function (data) {
+ $scope.lang = $scope.val['wt'];
+ if (!$scope.lang || $scope.lang === '') {
+ $scope.lang = "json";
+ }
+ $scope.response = data;
+ // Use relative URL to make it also work through proxies that may
have a different host/port/context
+ $scope.url = url;
+ $scope.hostPortContext = $location.absUrl().substr(0,
$location.absUrl().indexOf("#")); // For display only
+ });
+ } else {
+ var previousUrl = $location.$$url;
for( key in $location.search() ){
- $location.search(key, null);
+ $location.search(key, null);
}
for( var key in adminParams ){
if( Array.isArray(adminParams[key]) && adminParams[key].length === 1
){
@@ -198,7 +208,11 @@ solrAdminApp.controller('QueryController',
}
$location.search(key, adminParams[key]);
}
- });
+ var currentUrl = $location.$$url;
+ if (previousUrl === currentUrl) { //if the query send with same
parameters the query should be executed
+ $route.reload();
+ }
+ }
};
setModels("input");
setModels("textarea");
@@ -206,7 +220,7 @@ solrAdminApp.controller('QueryController',
setUrlParams();
if ($location.search().q) {
- $scope.doQuery();
+ $scope.doQuery(true);
}
$scope.removeFilter = function(index) {
if ($scope.filters.length === 1) {
@@ -218,5 +232,15 @@ solrAdminApp.controller('QueryController',
$scope.addFilter = function(index) {
$scope.filters.splice(index+1, 0, {fq:""});
};
+ $scope.removeRawParam = function (index) {
+ if ($scope.rawParams.length === 1) {
+ $scope.rawParams = [{rawParam: ""}];
+ } else {
+ $scope.rawParams.splice(index, 1);
+ }
+ };
+ $scope.addRawParam = function (index) {
+ $scope.rawParams.splice(index+1, 0, {rawParam:""});
+ };
}
);
diff --git a/solr/webapp/web/partials/query.html
b/solr/webapp/web/partials/query.html
index a09e968..6427a3a 100644
--- a/solr/webapp/web/partials/query.html
+++ b/solr/webapp/web/partials/query.html
@@ -346,12 +346,19 @@ limitations under the License.
<input type="text" ng-model="val['spellcheck.accuracy']"
name="spellcheck.accuracy" id="spellcheck_accuracy">
</div>
</fieldset>
- <fieldset class="additional optional">
- <label for="custom_parameters">
- <a rel="help">Raw Query Parameters</a>
- </label>
- <input type="text" ng-model="rawParams" id="custom_parameters"
value="" placeholder="key1=val1&key2=val2">
- </fieldset>
+ <label for="custom_parameters" title="Raw Query Parameters">
+ <a rel="help">Raw Query Parameters</a>
+ </label>
+ <div class="multiple" id="custom_parameters">
+ <div class="row clearfix" ng-repeat="param in rawParams">
+ <input type="text" ng-model="param.rawParam" name="rawParamQuery"
title="Raw param query.">
+ <div class="buttons">
+ <a class="rem" ng-click="removeRawParam($index)"><span></span></a>
+ <a class="add" ng-click="addRawParam($index)"><span></span></a>
+ </div>
+ </div>
+ </div>
+
<button type="submit" ng-click="doQuery()">Execute Query</button>
</form>