Skip to content

feat(config): switch Solr wire format from JavaBin to JSON#55

Open
adityamparikh wants to merge 6 commits intoapache:mainfrom
adityamparikh:feat/json-wire-format
Open

feat(config): switch Solr wire format from JavaBin to JSON#55
adityamparikh wants to merge 6 commits intoapache:mainfrom
adityamparikh:feat/json-wire-format

Conversation

@adityamparikh
Copy link
Contributor

Summary

  • Adds JsonResponseParser, a custom SolrJ ResponseParser that requests wt=json and converts Solr's JSON response into the NamedList object tree that SolrJ typed response classes expect internally
  • Wires it into SolrConfig via .withResponseParser(new JsonResponseParser()), replacing the default BinaryResponseParser (wt=javabin)
  • All existing behaviour is preserved — no changes to service layer code

Design

The converter handles four structural differences between JSON and JavaBin/XML:

JSON shape Converted to Reason
JSON object SimpleOrderedMap Extends NamedList (satisfies QueryResponse/CollectionService casts) and implements Map<String,T> (satisfies SchemaResponse's (Map) cast)
Object with numFound + docs SolrDocumentList QueryResponse does (SolrDocumentList) get("response")
Array ["term", 5, "term2", 3] SimpleOrderedMap Solr's json.nl=flat default encodes facet counts as alternating string/non-string pairs
Decimal numbers Float JavaBin encodes Solr floats as FLOAT; SchemaResponse does (Float) schema.get("version")

Test plan

  • ./gradlew build — all 212 existing tests pass, including SchemaServiceIntegrationTest and all other integration tests against a live Solr container

🤖 Generated with Claude Code

adityamparikh and others added 4 commits February 28, 2026 23:38
Replace the default BinaryResponseParser (wt=javabin) with a custom
JsonResponseParser (wt=json) for future-proofing and improved
debuggability.

The JsonResponseParser converts Solr's JSON response envelope into the
NamedList<Object> tree that SolrJ typed response classes expect:
- JSON objects → SimpleOrderedMap (extends NamedList, implements Map,
  satisfying both QueryResponse's NamedList casts and SchemaResponse's
  Map cast)
- JSON objects with numFound+docs → SolrDocumentList
- Flat alternating arrays [String, non-String, ...] → SimpleOrderedMap
  (Solr's json.nl=flat encoding for facet counts)
- All other arrays → List
- Decimal numbers → Float (matching JavaBin's float type, required by
  SchemaResponse's (Float) version cast)
- Small integers → Integer, large integers → Long

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: adityamparikh <aditya.m.parikh@gmail.com>
Extract JsonResponseParser instantiation into a dedicated @bean method
so it can be injected as a dependency into solrClient(), making the
wiring explicit and enabling overriding in tests.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: adityamparikh <aditya.m.parikh@gmail.com>
Replace the static new ObjectMapper() with Spring's auto-configured
ObjectMapper bean injected via constructor. Use MediaType.APPLICATION_JSON_VALUE
for the content type constant instead of a raw string literal.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: adityamparikh <aditya.m.parikh@gmail.com>
…'s ObjectMapper

Extract URL normalization tests from SolrConfigTest into a dedicated
SolrConfigUrlNormalizationTest annotated with @jsontest, so Spring's
auto-configured ObjectMapper is injected rather than using new ObjectMapper().

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: adityamparikh <aditya.m.parikh@gmail.com>
adityamparikh added a commit to adityamparikh/solr-mcp that referenced this pull request Mar 8, 2026
…o sb4

Incorporates:
- feat(config): switch Solr wire format from JavaBin to JSON (apache#55)
- fix(collection): catch RuntimeException from removed /admin/mbeans in Solr 10 (apache#59)
- feat(ci): add Solr 9.10 and 10 compatibility testing (apache#59)
- feat(deps): upgrade solr-solrj from 9.9.0 to 10.0.0 (apache#58)

Adapted JsonResponseParser for Jackson 3 (tools.jackson.databind).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: adityamparikh <aditya.m.parikh@gmail.com>
adityamparikh and others added 2 commits March 8, 2026 20:08
Replace unused catch variable with underscore unnamed pattern (S7467)
in SolrConfigUrlNormalizationTest - Java 25 feature.

Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com>

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: adityamparikh <aditya.m.parikh@gmail.com>
Signed-off-by: Aditya Parikh <adityamparikh@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant