Ivan Saric created SOLR-18641:
---------------------------------

             Summary: SolrJ SchemaRequest.MultiUpdate should send grouped 
command lists instead of repeated keys
                 Key: SOLR-18641
                 URL: https://issues.apache.org/jira/browse/SOLR-18641
             Project: Solr
          Issue Type: Improvement
          Components: SolrJ
            Reporter: Ivan Saric


SolrJ's {{SchemaRequest.MultiUpdate}} serialises its sub-requests by 
concatenating their request parameters into one {{NamedList}}, so a request 
with two {{AddField}} commands is sent as an object with the same key twice:

{code:json}
{"add-field":{"name":"f1","type":"string"},"add-field":{"name":"f2","type":"string"},"delete-field":{"name":"f0"}}
{code}

This works today: {{CommandOperation.parse}} reads the body key by key with a 
streaming parser and produces one command per key occurrence, and the Schema 
API reference guide ("Multiple Commands in a Single POST") documents the 
repeated-key form. {{SchemaRequestBodyTest.testMultiUpdateRepeatsCommandKeys}} 
pins the current output.

Repeated keys are, however, not JSON that an ordinary parser can round-trip 
(RFC 8259 says names SHOULD be unique and most parsers keep only the last 
value). Solr 11 is moving toward strict JSON input (see SOLR-18452). The same 
reference guide section documents a grouped form that the server already 
accepts:

{code:json}
{"add-field":[{"name":"f1","type":"string"},{"name":"f2","type":"string"}],"delete-field":{"name":"f0"}}
{code}

Proposal: have {{MultiUpdate.getRequestParameters()}} group *consecutive* 
commands of the same kind into a list under one key, and leave single commands 
as they are. Only consecutive commands may be merged: the Schema API executes 
commands in request order and the guide relies on that (e.g. an 
{{add-field-type}} must precede the {{add-field}} that uses it), so an 
add-field, add-field-type, add-field sequence must stay three keys. No server 
change is needed.

Scope: SolrJ only. Update {{SchemaRequestBodyTest}} to pin the new shape, and 
extend {{SchemaTest.testMultipleUpdateRequestAccuracy}} so it verifies every 
field the request adds.

Raised by David Smiley while reviewing https://github.com/apache/solr/pull/5311 
(discussion r4532521138).



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to