From 571b307266b8fd1011b10b4b2a442ae008aa9c41 Mon Sep 17 00:00:00 2001 From: Andrzej Bialecki Date: Fri, 15 Mar 2019 11:52:37 +0100 Subject: [PATCH] SOLR-13292: Fix a logic bug when point types are present, add more details to the unit test. --- .../admin/SegmentsInfoRequestHandler.java | 5 ++-- .../solr/cloud/CollectionsAPISolrJTest.java | 30 +++++++++++++++++-- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/handler/admin/SegmentsInfoRequestHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/SegmentsInfoRequestHandler.java index 5b37bbb0db1..3cc7a0926c9 100644 --- a/solr/core/src/java/org/apache/solr/handler/admin/SegmentsInfoRequestHandler.java +++ b/solr/core/src/java/org/apache/solr/handler/admin/SegmentsInfoRequestHandler.java @@ -386,8 +386,7 @@ public class SegmentsInfoRequestHandler extends RequestHandlerBase { nonCompliant.add("docValues", "schema=" + sf.getType().getUninversionType(sf) + ", segment=false"); } if (!sf.hasDocValues() && - fi.getDocValuesType() != DocValuesType.NONE && - fi.getIndexOptions() != IndexOptions.NONE) { + fi.getDocValuesType() != DocValuesType.NONE) { nonCompliant.add("docValues", "schema=false, segment=" + fi.getDocValuesType().toString()); } if (!sf.isPolyField()) { // difficult to find all sub-fields in a general way @@ -395,7 +394,7 @@ public class SegmentsInfoRequestHandler extends RequestHandlerBase { nonCompliant.add("indexed", "schema=" + sf.indexed() + ", segment=" + fi.getIndexOptions()); } } - if (sf.omitNorms() != (fi.omitsNorms() || hasPoints)) { + if (!hasPoints && (sf.omitNorms() != fi.omitsNorms())) { nonCompliant.add("omitNorms", "schema=" + sf.omitNorms() + ", segment=" + fi.omitsNorms()); } if (sf.storeTermVector() != fi.hasVectors()) { diff --git a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java index 42940a8c329..ce025671593 100644 --- a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java @@ -30,6 +30,7 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; import java.util.Collections; +import java.util.Date; import java.util.List; import java.util.Map; import java.util.Objects; @@ -83,6 +84,7 @@ public class CollectionsAPISolrJTest extends SolrCloudTestCase { public void beforeTest() throws Exception { configureCluster(4) .addConfig("conf", configset("cloud-minimal")) + .addConfig("conf2", configset("cloud-dynamic")) .configure(); // clear any persisted auto scaling configuration @@ -605,15 +607,36 @@ public class CollectionsAPISolrJTest extends SolrCloudTestCase { @Test public void testColStatus() throws Exception { final String collectionName = "collectionStatusTest"; - CollectionAdminRequest.createCollection(collectionName, "conf", 2, 2) + CollectionAdminRequest.createCollection(collectionName, "conf2", 2, 2) .process(cluster.getSolrClient()); cluster.waitForActiveCollection(collectionName, 2, 4); SolrClient client = cluster.getSolrClient(); + byte[] binData = collectionName.getBytes("UTF-8"); // index some docs for (int i = 0; i < 10; i++) { - client.add(collectionName, new SolrInputDocument("id", String.valueOf(i))); + SolrInputDocument doc = new SolrInputDocument(); + doc.addField("id", String.valueOf(i)); + doc.addField("number_i", i); + doc.addField("number_l", i); + doc.addField("number_f", i); + doc.addField("number_d", i); + doc.addField("number_ti", i); + doc.addField("number_tl", i); + doc.addField("number_tf", i); + doc.addField("number_td", i); + doc.addField("point", i + "," + i); + doc.addField("pointD", i + "," + i); + doc.addField("store", (i * 5) + "," + (i * 5)); + doc.addField("boolean_b", true); + doc.addField("multi_int_with_docvals", i); + doc.addField("string_s", String.valueOf(i)); + doc.addField("tv_mv_string", "this is a test " + i); + doc.addField("timestamp_dt", new Date()); + doc.addField("timestamp_tdt", new Date()); + doc.addField("payload", binData); + client.add(collectionName, doc); } client.commit(collectionName); @@ -624,6 +647,9 @@ public class CollectionsAPISolrJTest extends SolrCloudTestCase { req.setWithSizeInfo(true); CollectionAdminResponse rsp = req.process(cluster.getSolrClient()); assertEquals(0, rsp.getStatus()); + List nonCompliant = (List)rsp.getResponse().findRecursive(collectionName, "schemaNonCompliant"); + assertEquals(nonCompliant.toString(), 1, nonCompliant.size()); + assertTrue(nonCompliant.toString(), nonCompliant.contains("(NONE)")); NamedList segInfos = (NamedList) rsp.getResponse().findRecursive(collectionName, "shards", "shard1", "leader", "segInfos"); assertNotNull(Utils.toJSONString(rsp), segInfos.findRecursive("info", "core", "startTime")); assertNotNull(Utils.toJSONString(rsp), segInfos.get("fieldInfoLegend"));