You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mu...@apache.org on 2019/10/18 16:10:53 UTC

[lucene-solr] branch branch_8x updated (ab65f34 -> b8213ce)

This is an automated email from the ASF dual-hosted git repository.

munendrasn pushed a change to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git.


    from ab65f34  SOLR-13843: The MOVEREPLICA API ignores replica type and always adds 'nrt' replicas
     new 2cbe034  SOLR-13827: fail on unknown operation in Request Parameters API
     new b8213ce  SOLR-12769: correct documentation for delete op in request params API

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 solr/CHANGES.txt                                   |  6 +++--
 .../org/apache/solr/handler/SolrConfigHandler.java | 18 ++++++++------
 .../org/apache/solr/handler/TestReqParamsAPI.java  | 10 ++++++++
 .../solr/handler/TestSolrConfigHandlerCloud.java   |  9 +++++++
 .../solr-ref-guide/src/request-parameters-api.adoc | 29 +++++++++++++++++++---
 .../java/org/apache/solr/common/util/StrUtils.java |  2 +-
 .../apispec/core.config.Params.Commands.json       |  2 +-
 7 files changed, 61 insertions(+), 15 deletions(-)


[lucene-solr] 02/02: SOLR-12769: correct documentation for delete op in request params API

Posted by mu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

munendrasn pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git

commit b8213cef1a7a8c262a3e0184a380f0e83821d99e
Author: Munendra S N <mu...@apache.org>
AuthorDate: Fri Oct 18 21:13:35 2019 +0530

    SOLR-12769: correct documentation for delete op in request params API
---
 solr/CHANGES.txt                                   |  4 ++-
 .../solr-ref-guide/src/request-parameters-api.adoc | 29 +++++++++++++++++++---
 .../apispec/core.config.Params.Commands.json       |  2 +-
 3 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 3f0adb0..e1f61c9 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -48,11 +48,13 @@ Optimizations
 
 Bug Fixes
 ---------------------
+
 * SOLR-13827: Fail on unknown operation in Request Parameters API (Munendra S N, noble)
 
 Other Changes
 ---------------------
-(No changes)
+
+* SOLR-12769: Fix incorrect documentation for 'delete' op in Request parameters API (Alexandre Rafalovitch, Munendra S N)
 
 ==================  8.3.0 ==================
 
diff --git a/solr/solr-ref-guide/src/request-parameters-api.adoc b/solr/solr-ref-guide/src/request-parameters-api.adoc
index f76b2d8..047c1474 100644
--- a/solr/solr-ref-guide/src/request-parameters-api.adoc
+++ b/solr/solr-ref-guide/src/request-parameters-api.adoc
@@ -35,19 +35,19 @@ When might you want to use this feature?
 
 All requests are sent to the `/config/params` endpoint of the Config API.
 
-== Setting Request Parameters
+== Configuring Request Parameters
 
-The request to set, unset, or update request parameters is sent as a set of Maps with names. These objects can be directly used in a request or a request handler definition.
+The request to set, or update request parameters is sent as a set of Maps with names. These objects can be directly used in a request or a request handler definition. The request to delete parameter set is sent as list of names or a name.
 
 The available commands are:
 
 * `set`: Create or overwrite a parameter set map.
-* `unset`: delete a parameter set map.
+* `delete`: Remove a request parameter set map.
 * `update`: update a parameter set map. This is equivalent to a `map.putAll(newMap)`. Both the maps are merged and if the new map has same keys as old they are overwritten.
 
 You can mix these commands into a single request if necessary.
 
-Each map must include a name so it can be referenced later, either in a direct request to Solr or in a request handler definition.
+For `set` or `update` commands, each map must include a name so it can be referenced later, either in a direct request to Solr or in a request handler definition.
 
 In the following example, we are setting 2 sets of parameters named 'myFacets' and 'myQueries'.
 
@@ -83,6 +83,27 @@ curl http://localhost:8983/solr/techproducts/config/params -H 'Content-type:appl
 }'
 ----
 
+In the following example, two set of parameters named 'myFacets' and 'myQueries' are deleted.
+
+[source,bash]
+----
+curl http://localhost:8983/solr/techproducts/config/params -H 'Content-type:application/json'  -d '{
+  "delete":[
+    "myFacets",
+    "myQueries"
+  ]
+}'
+----
+
+When deleting a single parameter set, the value could be specified as string instead of list.
+
+[source,bash]
+----
+curl http://localhost:8983/solr/techproducts/config/params -H 'Content-type:application/json'  -d '{
+  "delete":"myFacets"
+}'
+----
+
 == Using Request Parameters with RequestHandlers
 
 After creating the `my_handler_params` paramset in the above section, it is possible to define a request handler as follows:
diff --git a/solr/solrj/src/resources/apispec/core.config.Params.Commands.json b/solr/solrj/src/resources/apispec/core.config.Params.Commands.json
index 675d9ee..2691c1c 100644
--- a/solr/solrj/src/resources/apispec/core.config.Params.Commands.json
+++ b/solr/solrj/src/resources/apispec/core.config.Params.Commands.json
@@ -15,7 +15,7 @@
       "description":"Add or overwrite one or more paramsets. Each paramset definition includes a paramset name, followed by key-value pairs of the parameter and value to be set.",
       "additionalProperties": true
     },
-    "unset": {
+    "delete": {
       "type":"array",
       "description": "Delete one or more paramsets.",
       "items": {


[lucene-solr] 01/02: SOLR-13827: fail on unknown operation in Request Parameters API

Posted by mu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

munendrasn pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git

commit 2cbe03429ef945cbcd1a97fe5107063479fab27f
Author: Munendra S N <mu...@apache.org>
AuthorDate: Fri Oct 18 21:08:33 2019 +0530

    SOLR-13827: fail on unknown operation in Request Parameters API
---
 solr/CHANGES.txt                                       |  2 +-
 .../org/apache/solr/handler/SolrConfigHandler.java     | 18 +++++++++++-------
 .../test/org/apache/solr/handler/TestReqParamsAPI.java | 10 ++++++++++
 .../solr/handler/TestSolrConfigHandlerCloud.java       |  9 +++++++++
 .../src/java/org/apache/solr/common/util/StrUtils.java |  2 +-
 5 files changed, 32 insertions(+), 9 deletions(-)

diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index d48640b..3f0adb0 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -48,7 +48,7 @@ Optimizations
 
 Bug Fixes
 ---------------------
-(No changes)
+* SOLR-13827: Fail on unknown operation in Request Parameters API (Munendra S N, noble)
 
 Other Changes
 ---------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/SolrConfigHandler.java b/solr/core/src/java/org/apache/solr/handler/SolrConfigHandler.java
index 11c6404..5952d80 100644
--- a/solr/core/src/java/org/apache/solr/handler/SolrConfigHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/SolrConfigHandler.java
@@ -152,7 +152,7 @@ public class SolrConfigHandler extends RequestHandlerBase implements SolrCoreAwa
     NamedList configSetProperties = core.getConfigSetProperties();
     if(configSetProperties == null) return false;
     Object immutable = configSetProperties.get(IMMUTABLE_CONFIGSET_ARG);
-    return immutable != null ? Boolean.parseBoolean(immutable.toString()) : false;
+    return immutable != null && Boolean.parseBoolean(immutable.toString());
   }
 
 
@@ -292,13 +292,13 @@ public class SolrConfigHandler extends RequestHandlerBase implements SolrCoreAwa
         pluginInfo = ((PluginInfo) plugin).toMap(new LinkedHashMap<>());
       }
       String useParams = (String) pluginInfo.get(USEPARAM);
-      String useparamsInReq = req.getOriginalParams().get(USEPARAM);
-      if (useParams != null || useparamsInReq != null) {
+      String useParamsInReq = req.getOriginalParams().get(USEPARAM);
+      if (useParams != null || useParamsInReq != null) {
         Map m = new LinkedHashMap<>();
         pluginInfo.put("_useParamsExpanded_", m);
         List<String> params = new ArrayList<>();
         if (useParams != null) params.addAll(StrUtils.splitSmart(useParams, ','));
-        if (useparamsInReq != null) params.addAll(StrUtils.splitSmart(useparamsInReq, ','));
+        if (useParamsInReq != null) params.addAll(StrUtils.splitSmart(useParamsInReq, ','));
         for (String param : params) {
           RequestParams.ParamSet p = this.req.getCore().getSolrConfig().getRequestParams().getParams(param);
           if (p != null) {
@@ -414,10 +414,14 @@ public class SolrConfigHandler extends RequestHandlerBase implements SolrCoreAwa
             if (op.hasError()) break;
             for (String s : name) {
               if (params.getParams(s) == null) {
-                op.addError(formatString("can't delete . No such params ''{0}'' exist", s));
+                op.addError(formatString("Could not delete. No such params ''{0}'' exist", s));
               }
               params = params.setParams(s, null);
             }
+            break;
+          }
+          default: {
+            op.unknownOperation();
           }
         }
       }
@@ -503,7 +507,7 @@ public class SolrConfigHandler extends RequestHandlerBase implements SolrCoreAwa
       } else {
         SolrResourceLoader.persistConfLocally(loader, ConfigOverlay.RESOURCE_NAME, overlay.toByteArray());
         req.getCore().getCoreContainer().reload(req.getCore().getName());
-        log.info("Executed config commands successfully and persited to File System {}", ops);
+        log.info("Executed config commands successfully and persisted to File System {}", ops);
       }
 
     }
@@ -769,7 +773,7 @@ public class SolrConfigHandler extends RequestHandlerBase implements SolrCoreAwa
 
         if (!success) {
           String coreUrl = concurrentTasks.get(f).coreUrl;
-          log.warn("Core " + coreUrl + "could not get the expected version " + expectedVersion);
+          log.warn("Core " + coreUrl + " could not get the expected version " + expectedVersion);
           if (failedList == null) failedList = new ArrayList<>();
           failedList.add(coreUrl);
         }
diff --git a/solr/core/src/test/org/apache/solr/handler/TestReqParamsAPI.java b/solr/core/src/test/org/apache/solr/handler/TestReqParamsAPI.java
index 7065b0d..da990da 100644
--- a/solr/core/src/test/org/apache/solr/handler/TestReqParamsAPI.java
+++ b/solr/core/src/test/org/apache/solr/handler/TestReqParamsAPI.java
@@ -297,5 +297,15 @@ public class TestReqParamsAPI extends SolrCloudTestCase {
         asList("response", "params", "y", "p"),
         null,
         10);
+
+    payload = " {'unset' : 'y'}";
+    TestSolrConfigHandler.runConfigCommandExpectFailure(
+        writeHarness,"/config/params", payload, "Unknown operation 'unset'");
+
+    // deleting already deleted one should fail
+    // error message should contain parameter set name
+    payload = " {'delete' : 'y'}";
+    TestSolrConfigHandler.runConfigCommandExpectFailure(
+        writeHarness,"/config/params", payload, "Could not delete. No such params 'y' exist");
   }
 }
diff --git a/solr/core/src/test/org/apache/solr/handler/TestSolrConfigHandlerCloud.java b/solr/core/src/test/org/apache/solr/handler/TestSolrConfigHandlerCloud.java
index 08af0a5..5b6c4f1 100644
--- a/solr/core/src/test/org/apache/solr/handler/TestSolrConfigHandlerCloud.java
+++ b/solr/core/src/test/org/apache/solr/handler/TestSolrConfigHandlerCloud.java
@@ -262,6 +262,15 @@ public class TestSolrConfigHandlerCloud extends AbstractFullDistribZkTestBase {
         null,
         TIMEOUT_S);
 
+    payload = " {'unset' : 'y'}";
+    TestSolrConfigHandler.runConfigCommandExpectFailure(
+        writeHarness,"/config/params", payload, "Unknown operation 'unset'");
+
+    // deleting already deleted one should fail
+    // error message should contain parameter set name
+    payload = " {'delete' : 'y'}";
+    TestSolrConfigHandler.runConfigCommandExpectFailure(
+        writeHarness,"/config/params", payload, "Could not delete. No such params 'y' exist");
 
   }
 
diff --git a/solr/solrj/src/java/org/apache/solr/common/util/StrUtils.java b/solr/solrj/src/java/org/apache/solr/common/util/StrUtils.java
index d153657..f9dd7c7 100644
--- a/solr/solrj/src/java/org/apache/solr/common/util/StrUtils.java
+++ b/solr/solrj/src/java/org/apache/solr/common/util/StrUtils.java
@@ -368,7 +368,7 @@ public class StrUtils {
   }
 
   /**
-   * Format using MesssageFormat but with the ROOT locale
+   * Format using {@link MessageFormat} but with the ROOT locale
    */
   public static String formatString(String pattern, Object... args) {
     return new MessageFormat(pattern, Locale.ROOT).format(args);