adityamparikh opened a new pull request, #289:
URL: https://github.com/apache/solr-mcp/pull/289

   ## Summary
   
   `JsonResponseParser` builds SolrJ's `NamedList` tree from Solr's JSON by 
guessing at shapes. Two guesses produce wrong output today:
   
   - `search` rounds every double field to float precision: a stored 
`1.1234567890123` comes back as `1.1234568`.
   - Luke fails with `Failed to parse Solr JSON response` on any collection 
with fields named `numFound` and `docs`, because its `fields` object looks like 
a result list.
   
   ```diff
    SearchService.search
      solrQuery
   +    json.nl=map                              # facet counts arrive as an 
object, not ["term",5,...]
   
    JsonResponseParser.convertValue
   -  array   → NamedList if it alternates [string, non-string, ...], or sits 
under facet_fields
   -          → otherwise List
   +  array   → List
   -  object  → SolrDocumentList if it has keys numFound and docs
   +  object  → SolrDocumentList if numFound is a number and docs is an array
              → otherwise NamedList
   -  decimal → Float
   +  decimal → Double inside a document's field values
   +          → Float elsewhere (SchemaResponse casts the schema version to 
Float)
   ```
   
   The wire format stays `wt=json`. The facet counts are the only plain 
`NamedList` the server reads; Luke, the Schema and Collections APIs, metrics, 
ping and cluster status are written as `SimpleOrderedMap`, which Solr always 
serializes as an object, whatever `json.nl` says.
   
   ## Evidence
   
   - **Before:** `search` returns `"price_d": 1.1234568` for a stored 
`1.1234567890123`; `LukeRequest` on a collection with fields `numFound` and 
`docs` throws.
     **After:** `JsonWireFormatIntegrationTest` (real Solr): `price_d` is 
`1.1234567890123`, a one-value multi-valued field stays a list, a facet with no 
matches is empty, and Luke lists `numFound` and `docs` as fields.
   - `JsonResponseParserTest`: facet objects and empty facets become 
`NamedList`s, arrays stay lists whatever they hold, a Luke-shaped object stays 
a `NamedList`, document decimals are `Double`, and `SchemaResponse` still reads 
the version as `Float`. 
`SearchServiceTest.search_AsksForNamedListsAsJsonObjects` pins the parameter.
   - Full suite, 0 failures, 0 skipped:
   
     | Run | Tests |
     |---|---|
     | `./gradlew build` (`solr:9.9.0-slim`) | 467 |
     | `-Dsolr.test.image=solr:9.4-slim` | 466 |
     | `-Dsolr.test.image=solr:10.0.0-slim` | 466 |
     | `./gradlew nativeTest -Pnative` | 310 run, 154 disabled in native |
   
     10.1 (`10-slim`) cannot boot until #285 lands.
   
   For comparison, the same suite and probe were run with SolrJ's own parsers 
in place of this one. `XMLResponseParser` collapses a one-value multi-valued 
field to a scalar (`readDocument` adds array elements one by one). 
`JavaBinResponseParser` is exact, and passed in the native image without extra 
hints, but needs a binary wire format; this change keeps JSON.
   
   ## Merge Danger
   
   **Door:** two-way
   
   Revert restores the old parser and drops one query parameter.
   
   **Blast Radius:** responses
   
   Every Solr response goes through this parser. Visible change in tool output: 
double fields in `search` results now carry full precision. A future call that 
reads a plain `NamedList` (range facets, the terms component) needs 
`json.nl=map` on its request, or it arrives as a list and fails at SolrJ's 
`NamedList` cast.
   
   🤖 Generated with [Claude Code](https://claude.com/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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

  • [PR] fix(config): stop JsonRes... adityamparikh (via GitHub) via issues

Reply via email to