Skip to content

Commit 06b9134

Browse files
committed
don't show nulled out fields with show=schema
1 parent 1cd6ac6 commit 06b9134

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

solr/core/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,11 @@ private void mergeDistributedResponses(SolrQueryResponse rsp, List<ShardResponse
384384
NamedList<Object> shardRsp = srsp.getSolrResponse().getResponse();
385385
LukeResponse lukeRsp = new LukeResponse();
386386
lukeRsp.setResponse(shardRsp);
387-
ShardData shardData = new ShardData(shardAddress(srsp), lukeRsp.getFieldInfo());
387+
// Only process field info if the shard explicitly included it in its response.
388+
// LukeResponse.getFieldInfo() falls back to schema.fields which has incomplete data.
389+
Map<String, LukeResponse.FieldInfo> fieldInfo =
390+
shardRsp.get(RSP_FIELDS) != null ? lukeRsp.getFieldInfo() : null;
391+
ShardData shardData = new ShardData(shardAddress(srsp), fieldInfo);
388392

389393
NamedList<Object> shardIndex = lukeRsp.getIndexInfo();
390394
if (shardIndex != null) {

solr/core/src/test/org/apache/solr/handler/admin/LukeRequestHandlerDistribTest.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,38 @@ public void testSparseShards() throws Exception {
289289
}
290290
}
291291

292+
@Test
293+
@SuppressWarnings("unchecked")
294+
public void testDistribShowSchema() throws Exception {
295+
ModifiableSolrParams params = new ModifiableSolrParams();
296+
params.set("distrib", "true");
297+
params.set("show", "schema");
298+
299+
LukeResponse rsp = requestLuke(COLLECTION, params);
300+
301+
NamedList<Object> raw = rsp.getResponse();
302+
NamedList<Object> schema = (NamedList<Object>) raw.get("schema");
303+
assertNotNull("schema section should be present", schema);
304+
305+
NamedList<Object> fields = (NamedList<Object>) schema.get("fields");
306+
assertNotNull("schema fields should be present", fields);
307+
assertNotNull("'id' should be in schema fields", fields.get("id"));
308+
assertNotNull("'name' should be in schema fields", fields.get("name"));
309+
310+
assertNotNull("dynamicFields should be present", schema.get("dynamicFields"));
311+
assertNotNull("uniqueKeyField should be present", schema.get("uniqueKeyField"));
312+
assertEquals("uniqueKeyField should be 'id'", "id", schema.get("uniqueKeyField"));
313+
assertNotNull("types should be present", schema.get("types"));
314+
assertNotNull("similarity should be present", schema.get("similarity"));
315+
316+
// show=schema should not produce merged top-level fields (matches local mode behavior)
317+
assertNull("top-level fields should not be present with show=schema", raw.get("fields"));
318+
319+
// Shards are present for consistency: each shard entry mirrors the per-shard index info,
320+
// just as the top-level index section is present in local mode with show=schema
321+
assertNotNull("shards should still be present with show=schema", raw.get("shards"));
322+
}
323+
292324
@Test
293325
public void testDistribTrueOnSingleShardFallsBackToLocal() throws Exception {
294326
String singleShardCollection = "lukeSingleShard";

0 commit comments

Comments
 (0)