You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by "janhoy (via GitHub)" <gi...@apache.org> on 2026/09/24 15:54:56 UTC

[PR] Fix incorrect v2 API examples in the Schema API ref guide [solr]

janhoy opened a new pull request, #4942:
URL: https://github.com/apache/solr/pull/4942

   # Description                                                                                                                                                                                            
                                                                                                                                                                                                              
   Three "V2 API" examples in the Schema API ref guide don't work as printed. I hit this trying to edit schema fields over v2.                                                                                          
                                                                                                                                                                                                              
     1. **Both copy-field V2 tabs point at a GET-only endpoint.** They POST a v1 keyed-object body to /api/collections/techproducts/schema`, which only carries `@GET`, so it answers `405` with `Allow:     
     GET,OPTIONS` and an empty body — no hint that `/schema/bulk` is one segment away.                                                                                                                        
     2. **The one correct bulk example is invalid JSON** — missing comma after each `"operationType"`.                                                                                                        
     3. **That same snippet uses the v1 prefix** `/solr/<coll>/schema/bulk`, which doesn't resolve the JAX-RS resource; it falls through to managed-resource handling under the v1 `SchemaHandler`: `400      
     "Expected Map to create a new ManagedResource but received a java.util.ArrayList"`.                                                                                                                      
                                                                                                                                                                                                              
   # Solution                                                                                                                                                                                               
                                                                                                                                                                                                              
   Both copy-field tabs now use `POST /api/collections/<coll>/schema/bulk` with the `operationType`-discriminated list form; the bulk example gets its commas and the `/api/...` prefix. Also documented that v2 names the attribute `destinations` — an **alias**, not a rename (`@JsonAlias("dest")`, `dest` still parses) — and that `/schema` is GET-only in v2, so the bulk endpoint is discoverable from the prose.                                                                                                                                                                                                   
                                                                                                                                                                                                                                                                                                                                                                                                                         
   # Tests                                                                                                                                                                                                  
                                                                                                                                                                                                              
   Verified against a live Solr 10.0.0 SolrCloud node: reproduced both original failures, confirmed every path in the file now routes (reads `200`, writes reach `SchemaManager`), and confirmed the corrected copy-field bodies parse and validate, including via the `dest` alias. Probes used invalid payloads and nonexistent field names, with zero schema residue afterwards. Every JSON payload in the file now parses except the two **v1** examples with deliberately repeated keys, which noggit accepts by design. `buildLocalAntoraSite` clean, no new warnings. 
   
   Written with the assistance of Claude Code


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] Fix incorrect v2 API examples in the Schema API ref guide [solr]

Posted by "epugh (via GitHub)" <gi...@apache.org>.
epugh commented on code in PR #4942:
URL: https://github.com/apache/solr/pull/4942#discussion_r4100934919


##########
solr/solr-ref-guide/modules/indexing-guide/pages/schema-api.adoc:
##########
@@ -523,11 +524,13 @@ V2 API::
 ====
 [source,bash]
 ----
-curl -X POST -H 'Content-type:application/json' --data-binary '{
-  "add-copy-field":{
-     "source":"shelf",
-     "dest":[ "location", "catchall" ]}
-}' http://localhost:8983/api/collections/techproducts/schema
+curl -X POST -H 'Content-type:application/json' --data-binary '[
+  {
+    "operationType":"add-copy-field",
+    "source":"shelf",
+    "destinations":[ "location", "catchall" ]
+  }
+]' http://localhost:8983/api/collections/techproducts/schema/bulk

Review Comment:
   https://github.com/apache/solr/pull/4925 is where this is proposed...



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] Fix incorrect v2 API examples in the Schema API ref guide [solr]

Posted by "janhoy (via GitHub)" <gi...@apache.org>.
janhoy commented on code in PR #4942:
URL: https://github.com/apache/solr/pull/4942#discussion_r4104125507


##########
solr/solr-ref-guide/modules/indexing-guide/pages/schema-api.adoc:
##########
@@ -523,11 +524,13 @@ V2 API::
 ====
 [source,bash]
 ----
-curl -X POST -H 'Content-type:application/json' --data-binary '{
-  "add-copy-field":{
-     "source":"shelf",
-     "dest":[ "location", "catchall" ]}
-}' http://localhost:8983/api/collections/techproducts/schema
+curl -X POST -H 'Content-type:application/json' --data-binary '[
+  {
+    "operationType":"add-copy-field",
+    "source":"shelf",
+    "destinations":[ "location", "catchall" ]

Review Comment:
   V1 uses `dest`, and the GET endpoint listing all copyfield rules will return json objects with `dest` keys. Thus it would be nice if the request and response shapes use same keys.
   
   Some of this may be thrown in the air by #4943 eventually, this PR is more to fix erraneous docs on the current main branch as it sits.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] Fix incorrect v2 API examples in the Schema API ref guide [solr]

Posted by "janhoy (via GitHub)" <gi...@apache.org>.
janhoy commented on code in PR #4942:
URL: https://github.com/apache/solr/pull/4942#discussion_r4104139522


##########
solr/solr-ref-guide/modules/indexing-guide/pages/schema-api.adoc:
##########
@@ -523,11 +524,13 @@ V2 API::
 ====
 [source,bash]
 ----
-curl -X POST -H 'Content-type:application/json' --data-binary '{
-  "add-copy-field":{
-     "source":"shelf",
-     "dest":[ "location", "catchall" ]}
-}' http://localhost:8983/api/collections/techproducts/schema
+curl -X POST -H 'Content-type:application/json' --data-binary '[
+  {
+    "operationType":"add-copy-field",
+    "source":"shelf",
+    "destinations":[ "location", "catchall" ]
+  }
+]' http://localhost:8983/api/collections/techproducts/schema/bulk

Review Comment:
   These two will conflict, but let's handle conflicts during merge (whichever lands first), not try to align up front?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] Fix incorrect v2 API examples in the Schema API ref guide [solr]

Posted by "janhoy (via GitHub)" <gi...@apache.org>.
janhoy commented on code in PR #4942:
URL: https://github.com/apache/solr/pull/4942#discussion_r4104147458


##########
solr/solr-ref-guide/modules/indexing-guide/pages/schema-api.adoc:
##########
@@ -636,31 +639,32 @@ curl -X POST -H 'Content-type:application/json' --data-binary '{
 }' http://localhost:8983/solr/techproducts/schema
 ----
 
-Bulk schema operations are also supported in Solr's v2 API, using a slightly different syntax.
+Bulk schema operations are also supported in Solr's v2 API, using a different endpoint and syntax.
+The v2 bulk endpoint is `POST /api/collections/_collection_/schema/bulk`; the `/schema` path itself only supports `GET` in v2.
 Individual operations are specified as elements within a list, with the operation name (e.g. `add-field`, `delete-field-type`) specified as a `"operationType"` property on each operation object:
 
 [source,bash]
 ----
 curl -X POST -H 'Content-type:application/json' --data-binary '
   [
     {
-      "operationType": "add-field"
+      "operationType": "add-field",

Review Comment:
   Noggit won't complain even if you feed it a rat :) Which is bad, and we should not recommend broken JSON in our docs.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] Fix incorrect v2 API examples in the Schema API ref guide [solr]

Posted by "epugh (via GitHub)" <gi...@apache.org>.
epugh commented on code in PR #4942:
URL: https://github.com/apache/solr/pull/4942#discussion_r4100924652


##########
solr/solr-ref-guide/modules/indexing-guide/pages/schema-api.adoc:
##########
@@ -523,11 +524,13 @@ V2 API::
 ====
 [source,bash]
 ----
-curl -X POST -H 'Content-type:application/json' --data-binary '{
-  "add-copy-field":{
-     "source":"shelf",
-     "dest":[ "location", "catchall" ]}
-}' http://localhost:8983/api/collections/techproducts/schema
+curl -X POST -H 'Content-type:application/json' --data-binary '[

Review Comment:
   in anohter PR, I think we are prposing that we don't need -X POST IF you are doing a data binary...   Also, `-d`,
   
   
   ```suggestion
   curl -H 'Content-type:application/json' -d '[
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] Fix incorrect v2 API examples in the Schema API ref guide [solr]

Posted by "epugh (via GitHub)" <gi...@apache.org>.
epugh commented on code in PR #4942:
URL: https://github.com/apache/solr/pull/4942#discussion_r4100930370


##########
solr/solr-ref-guide/modules/indexing-guide/pages/schema-api.adoc:
##########
@@ -523,11 +524,13 @@ V2 API::
 ====
 [source,bash]
 ----
-curl -X POST -H 'Content-type:application/json' --data-binary '{
-  "add-copy-field":{
-     "source":"shelf",
-     "dest":[ "location", "catchall" ]}
-}' http://localhost:8983/api/collections/techproducts/schema
+curl -X POST -H 'Content-type:application/json' --data-binary '[
+  {
+    "operationType":"add-copy-field",
+    "source":"shelf",
+    "destinations":[ "location", "catchall" ]
+  }
+]' http://localhost:8983/api/collections/techproducts/schema/bulk

Review Comment:
   oh, I think we changed this so that the url is at the beginning, not the end.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] Fix incorrect v2 API examples in the Schema API ref guide [solr]

Posted by "epugh (via GitHub)" <gi...@apache.org>.
epugh commented on code in PR #4942:
URL: https://github.com/apache/solr/pull/4942#discussion_r4100938348


##########
solr/solr-ref-guide/modules/indexing-guide/pages/schema-api.adoc:
##########
@@ -559,9 +562,9 @@ V2 API::
 ====
 [source,bash]
 ----
-curl -X POST -H 'Content-type:application/json' --data-binary '{
-  "delete-copy-field":{ "source":"shelf", "dest":"location" }
-}' http://localhost:8983/api/collections/techproducts/schema
+curl -X POST -H 'Content-type:application/json' --data-binary '[
+  { "operationType":"delete-copy-field", "source":"shelf", "destinations":[ "location" ] }

Review Comment:
   operationType?  operation-type?   I guess this is just documenting the existing actual implmeentaiton.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] Fix incorrect v2 API examples in the Schema API ref guide [solr]

Posted by "janhoy (via GitHub)" <gi...@apache.org>.
janhoy commented on code in PR #4942:
URL: https://github.com/apache/solr/pull/4942#discussion_r4099407584


##########
solr/solr-ref-guide/modules/indexing-guide/pages/schema-api.adoc:
##########
@@ -523,11 +524,13 @@ V2 API::
 ====
 [source,bash]
 ----
-curl -X POST -H 'Content-type:application/json' --data-binary '{
-  "add-copy-field":{
-     "source":"shelf",
-     "dest":[ "location", "catchall" ]}
-}' http://localhost:8983/api/collections/techproducts/schema
+curl -X POST -H 'Content-type:application/json' --data-binary '[
+  {
+    "operationType":"add-copy-field",
+    "source":"shelf",
+    "destinations":[ "location", "catchall" ]

Review Comment:
   See #4943 for code work on the same. Need to decide between "destination" and "dest". 
   Also, if the destination fields require different `maxChars` settings, then you'll need to POST several requests, as the body JSON format here can only specify a global `maxChars` setting.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] Fix incorrect v2 API examples in the Schema API ref guide [solr]

Posted by "epugh (via GitHub)" <gi...@apache.org>.
epugh commented on code in PR #4942:
URL: https://github.com/apache/solr/pull/4942#discussion_r4100940703


##########
solr/solr-ref-guide/modules/indexing-guide/pages/schema-api.adoc:
##########
@@ -636,31 +639,32 @@ curl -X POST -H 'Content-type:application/json' --data-binary '{
 }' http://localhost:8983/solr/techproducts/schema
 ----
 
-Bulk schema operations are also supported in Solr's v2 API, using a slightly different syntax.
+Bulk schema operations are also supported in Solr's v2 API, using a different endpoint and syntax.
+The v2 bulk endpoint is `POST /api/collections/_collection_/schema/bulk`; the `/schema` path itself only supports `GET` in v2.
 Individual operations are specified as elements within a list, with the operation name (e.g. `add-field`, `delete-field-type`) specified as a `"operationType"` property on each operation object:
 
 [source,bash]
 ----
 curl -X POST -H 'Content-type:application/json' --data-binary '
   [
     {
-      "operationType": "add-field"
+      "operationType": "add-field",

Review Comment:
   i wonder if this was valid under Noggit rules???  but yeah, lets fix it!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] Fix incorrect v2 API examples in the Schema API ref guide [solr]

Posted by "epugh (via GitHub)" <gi...@apache.org>.
epugh commented on code in PR #4942:
URL: https://github.com/apache/solr/pull/4942#discussion_r4100928727


##########
solr/solr-ref-guide/modules/indexing-guide/pages/schema-api.adoc:
##########
@@ -523,11 +524,13 @@ V2 API::
 ====
 [source,bash]
 ----
-curl -X POST -H 'Content-type:application/json' --data-binary '{
-  "add-copy-field":{
-     "source":"shelf",
-     "dest":[ "location", "catchall" ]}
-}' http://localhost:8983/api/collections/techproducts/schema
+curl -X POST -H 'Content-type:application/json' --data-binary '[
+  {
+    "operationType":"add-copy-field",
+    "source":"shelf",
+    "destinations":[ "location", "catchall" ]

Review Comment:
   json is so verbose already, so I don't mind `destinations`.   Do we use `dest` or `destinations` in any other locations????   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] Fix incorrect v2 API examples in the Schema API ref guide [solr]

Posted by "janhoy (via GitHub)" <gi...@apache.org>.
janhoy merged PR #4942:
URL: https://github.com/apache/solr/pull/4942


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] Fix incorrect v2 API examples in the Schema API ref guide [solr]

Posted by "epugh (via GitHub)" <gi...@apache.org>.
epugh commented on PR #4942:
URL: https://github.com/apache/solr/pull/4942#issuecomment-5980599307

   @janhoy I think this is ready for merging....   You are right that furthur chagnes cna be made when 4943 lands.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] Fix incorrect v2 API examples in the Schema API ref guide [solr]

Posted by "janhoy (via GitHub)" <gi...@apache.org>.
janhoy commented on PR #4942:
URL: https://github.com/apache/solr/pull/4942#issuecomment-5817534303

   Found this authoring a hands-on lab for our Solr training course.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org