You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ab...@apache.org on 2017/04/11 09:19:35 UTC
[14/23] lucene-solr:jira/solr-9959: SOLR-10437: Improve test coverage
of useDocValuesAsStored=false
SOLR-10437: Improve test coverage of useDocValuesAsStored=false
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/ce75eb62
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/ce75eb62
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/ce75eb62
Branch: refs/heads/jira/solr-9959
Commit: ce75eb62e9fd3256bcab23e7f1d901fec7c65115
Parents: b2a6310
Author: Tomas Fernandez Lobbe <tf...@apache.org>
Authored: Fri Apr 7 11:36:22 2017 -0700
Committer: Tomas Fernandez Lobbe <tf...@apache.org>
Committed: Fri Apr 7 11:36:22 2017 -0700
----------------------------------------------------------------------
.../solr/collection1/conf/schema-point.xml | 5 ++
.../org/apache/solr/schema/TestPointFields.java | 71 +++++++++++---------
.../solr/schema/TestUseDocValuesAsStored.java | 28 ++++++++
3 files changed, 71 insertions(+), 33 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/ce75eb62/solr/core/src/test-files/solr/collection1/conf/schema-point.xml
----------------------------------------------------------------------
diff --git a/solr/core/src/test-files/solr/collection1/conf/schema-point.xml b/solr/core/src/test-files/solr/collection1/conf/schema-point.xml
index 1a936a0..ae6a11e 100644
--- a/solr/core/src/test-files/solr/collection1/conf/schema-point.xml
+++ b/solr/core/src/test-files/solr/collection1/conf/schema-point.xml
@@ -54,6 +54,7 @@
<dynamicField name="*_p_i_ni" type="pint" indexed="false" stored="true" docValues="false"/>
<dynamicField name="*_p_i_ni_dv" type="pint" indexed="false" stored="true" docValues="true"/>
<dynamicField name="*_p_i_ni_dv_ns" type="pint" indexed="false" stored="false" docValues="true" useDocValuesAsStored="false"/>
+ <dynamicField name="*_p_i_ni_dv_ns_mv" type="pint" indexed="false" stored="false" docValues="true" useDocValuesAsStored="false" multiValued="true"/>
<dynamicField name="*_p_i_ni_mv" type="pint" indexed="false" stored="true" docValues="false" multiValued="true"/>
<dynamicField name="*_p_i_ni_mv_dv" type="pint" indexed="false" stored="true" docValues="true" multiValued="true"/>
<dynamicField name="*_p_i_ni_ns" type="pint" indexed="false" stored="false" docValues="false" />
@@ -66,6 +67,7 @@
<dynamicField name="*_p_l_ni" type="plong" indexed="false" stored="true" docValues="false"/>
<dynamicField name="*_p_l_ni_dv" type="plong" indexed="false" stored="true" docValues="true"/>
<dynamicField name="*_p_l_ni_dv_ns" type="plong" indexed="false" stored="false" docValues="true" useDocValuesAsStored="false"/>
+ <dynamicField name="*_p_l_ni_dv_ns_mv" type="plong" indexed="false" stored="false" docValues="true" useDocValuesAsStored="false" multiValued="true"/>
<dynamicField name="*_p_l_ni_mv" type="plong" indexed="false" stored="true" docValues="false" multiValued="true"/>
<dynamicField name="*_p_l_ni_mv_dv" type="plong" indexed="false" stored="true" docValues="true" multiValued="true"/>
<dynamicField name="*_p_l_ni_ns" type="plong" indexed="false" stored="false" docValues="false" />
@@ -78,6 +80,7 @@
<dynamicField name="*_p_d_ni" type="pdouble" indexed="false" stored="true" docValues="false"/>
<dynamicField name="*_p_d_ni_dv" type="pdouble" indexed="false" stored="true" docValues="true"/>
<dynamicField name="*_p_d_ni_dv_ns" type="pdouble" indexed="false" stored="false" docValues="true" useDocValuesAsStored="false"/>
+ <dynamicField name="*_p_d_ni_dv_ns_mv" type="pdouble" indexed="false" stored="false" docValues="true" useDocValuesAsStored="false" multiValued="true"/>
<dynamicField name="*_p_d_ni_mv" type="pdouble" indexed="false" stored="true" docValues="false" multiValued="true"/>
<dynamicField name="*_p_d_ni_mv_dv" type="pdouble" indexed="false" stored="true" docValues="true" multiValued="true"/>
<dynamicField name="*_p_d_ni_ns" type="pdouble" indexed="false" stored="false" docValues="false"/>
@@ -90,6 +93,7 @@
<dynamicField name="*_p_f_ni" type="pfloat" indexed="false" stored="true" docValues="false"/>
<dynamicField name="*_p_f_ni_dv" type="pfloat" indexed="false" stored="true" docValues="true"/>
<dynamicField name="*_p_f_ni_dv_ns" type="pfloat" indexed="false" stored="false" docValues="true" useDocValuesAsStored="false"/>
+ <dynamicField name="*_p_f_ni_dv_ns_mv" type="pfloat" indexed="false" stored="false" docValues="true" useDocValuesAsStored="false" multiValued="true"/>
<dynamicField name="*_p_f_ni_mv" type="pfloat" indexed="false" stored="true" docValues="false" multiValued="true"/>
<dynamicField name="*_p_f_ni_mv_dv" type="pfloat" indexed="false" stored="true" docValues="true" multiValued="true"/>
<dynamicField name="*_p_f_ni_ns" type="pfloat" indexed="false" stored="false" docValues="false"/>
@@ -102,6 +106,7 @@
<dynamicField name="*_p_dt_ni" type="pdate" indexed="false" stored="true" docValues="false"/>
<dynamicField name="*_p_dt_ni_dv" type="pdate" indexed="false" stored="true" docValues="true"/>
<dynamicField name="*_p_dt_ni_dv_ns" type="pdate" indexed="false" stored="false" docValues="true" useDocValuesAsStored="false"/>
+ <dynamicField name="*_p_dt_ni_dv_ns_mv" type="pdate" indexed="false" stored="false" docValues="true" useDocValuesAsStored="false" multiValued="true"/>
<dynamicField name="*_p_dt_ni_mv" type="pdate" indexed="false" stored="true" docValues="false" multiValued="true"/>
<dynamicField name="*_p_dt_ni_mv_dv" type="pdate" indexed="false" stored="true" docValues="true" multiValued="true"/>
<dynamicField name="*_p_dt_ni_ns" type="pdate" indexed="false" stored="false" docValues="false"/>
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/ce75eb62/solr/core/src/test/org/apache/solr/schema/TestPointFields.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/schema/TestPointFields.java b/solr/core/src/test/org/apache/solr/schema/TestPointFields.java
index de45844..18ac3b2 100644
--- a/solr/core/src/test/org/apache/solr/schema/TestPointFields.java
+++ b/solr/core/src/test/org/apache/solr/schema/TestPointFields.java
@@ -17,6 +17,7 @@
package org.apache.solr.schema;
import java.io.IOException;
+import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
@@ -57,7 +58,6 @@ import org.junit.Test;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
-import com.ibm.icu.text.SimpleDateFormat;
/**
* Tests for PointField functionality
@@ -885,7 +885,7 @@ public class TestPointFields extends SolrTestCaseJ4 {
public void testInternals() throws IOException {
String[] types = new String[]{"i", "l", "f", "d"};
- String[] suffixes = new String[]{"", "_dv", "_mv", "_mv_dv", "_ni", "_ni_dv", "_ni_dv_ns", "_ni_mv", "_ni_mv_dv", "_ni_ns", "_ni_ns_mv", "_dv_ns", "_ni_ns_dv", "_dv_ns_mv"};
+ String[] suffixes = new String[]{"", "_dv", "_mv", "_mv_dv", "_ni", "_ni_dv", "_ni_dv_ns", "_ni_dv_ns_mv", "_ni_mv", "_ni_mv_dv", "_ni_ns", "_ni_ns_mv", "_dv_ns", "_ni_ns_dv", "_dv_ns_mv"};
Set<String> typesTested = new HashSet<>();
for (String type:types) {
for (String suffix:suffixes) {
@@ -2696,38 +2696,36 @@ public class TestPointFields extends SolrTestCaseJ4 {
public void testNonReturnable() throws Exception {
- doTestNonReturnable("foo_p_i_ni_ns", "42");
- doTestNonReturnable("foo_p_i_ni_ns_mv", "42", "666");
+ doTestReturnNonStored("foo_p_i_ni_ns", false, "42");
+ doTestReturnNonStored("foo_p_i_ni_dv_ns", true, "42");
+ doTestReturnNonStored("foo_p_i_ni_ns_mv", false, "42", "666");
+ doTestReturnNonStored("foo_p_i_ni_dv_ns_mv", true, "42", "666");
- doTestNonReturnable("foo_p_l_ni_ns", "3333333333");
- doTestNonReturnable("foo_p_l_ni_ns_mv", "3333333333", "-4444444444");
+ doTestReturnNonStored("foo_p_l_ni_ns", false, "3333333333");
+ doTestReturnNonStored("foo_p_l_ni_dv_ns", true, "3333333333");
+ doTestReturnNonStored("foo_p_l_ni_ns_mv", false, "3333333333", "-4444444444");
+ doTestReturnNonStored("foo_p_l_ni_dv_ns_mv", true, "3333333333", "-4444444444");
- doTestNonReturnable("foo_p_f_ni_ns", "42.3");
- doTestNonReturnable("foo_p_f_ni_ns_mv", "42.3", "-66.6");
+ doTestReturnNonStored("foo_p_f_ni_ns", false, "42.3");
+ doTestReturnNonStored("foo_p_f_ni_dv_ns", true, "42.3");
+ doTestReturnNonStored("foo_p_f_ni_ns_mv", false, "42.3", "-66.6");
+ doTestReturnNonStored("foo_p_f_ni_dv_ns_mv", true, "42.3", "-66.6");
- doTestNonReturnable("foo_p_d_ni_ns", "42.3");
- doTestNonReturnable("foo_p_d_ni_ns_mv", "42.3", "-66.6");
+ doTestReturnNonStored("foo_p_d_ni_ns", false, "42.3");
+ doTestReturnNonStored("foo_p_d_ni_dv_ns", true, "42.3");
+ doTestReturnNonStored("foo_p_d_ni_ns_mv", false, "42.3", "-66.6");
+ doTestReturnNonStored("foo_p_d_ni_dv_ns_mv", true, "42.3", "-66.6");
- doTestNonReturnable("foo_p_dt_ni_ns", "1995-12-31T23:59:59Z");
- doTestNonReturnable("foo_p_dt_ni_ns_mv", "1995-12-31T23:59:59Z", "2000-12-31T23:59:59Z+3DAYS");
-
- }
-
- @AwaitsFix(bugUrl="https://issues.apache.org/jira/browse/SOLR-10437")
- public void testNonReturnableDocValues() throws Exception {
- // TODO: once SOLR-10437 is resolved, this test method can be folded into testNonReturnable()
-
- // these fields are stored=false, docValues=true, useDocValuesAsStored=false and yet they are
- // still returned and failing this test.
-
- doTestNonReturnable("foo_p_i_ni_dv_ns", "42");
- doTestNonReturnable("foo_p_l_ni_dv_ns", "3333333333");
- doTestNonReturnable("foo_p_f_ni_dv_ns", "42.3");
- doTestNonReturnable("foo_p_d_ni_dv_ns", "42.3");
- doTestNonReturnable("foo_p_dt_ni_dv_ns", "1995-12-31T23:59:59Z");
+ doTestReturnNonStored("foo_p_dt_ni_ns", false, "1995-12-31T23:59:59Z");
+ doTestReturnNonStored("foo_p_dt_ni_dv_ns", true, "1995-12-31T23:59:59Z");
+ doTestReturnNonStored("foo_p_dt_ni_ns_mv", false, "1995-12-31T23:59:59Z", "2000-12-31T23:59:59Z+3DAYS");
+ doTestReturnNonStored("foo_p_dt_ni_dv_ns_mv", true, "1995-12-31T23:59:59Z", "2000-12-31T23:59:59Z+3DAYS");
}
- public void doTestNonReturnable(final String fieldName, final String... values) throws Exception {
+ public void doTestReturnNonStored(final String fieldName, boolean shouldReturnFieldIfRequested, final String... values) throws Exception {
+ final String RETURN_FIELD = "count(//doc/*[@name='" + fieldName + "'])=10";
+ final String DONT_RETURN_FIELD = "count(//doc/*[@name='" + fieldName + "'])=0";
+ assertFalse(h.getCore().getLatestSchema().getField(fieldName).stored());
for (int i=0; i < 10; i++) {
SolrInputDocument doc = sdoc("id", String.valueOf(i));
for (String value : values) {
@@ -2739,17 +2737,24 @@ public class TestPointFields extends SolrTestCaseJ4 {
assertQ(req("q", "*:*", "rows", "100", "fl", "id," + fieldName),
"//*[@numFound='10']",
"count(//doc)=10", // exactly 10 docs in response
- "count(//doc/*)=10", // exactly 10 fields across all docs
- "count(//doc/*[@name!='id'])=0"); // no field in any doc other then 'id'
+ (shouldReturnFieldIfRequested?RETURN_FIELD:DONT_RETURN_FIELD)); // no field in any doc other then 'id'
+
+ assertQ(req("q", "*:*", "rows", "100", "fl", "*"),
+ "//*[@numFound='10']",
+ "count(//doc)=10", // exactly 10 docs in response
+ DONT_RETURN_FIELD); // no field in any doc other then 'id'
+
+ assertQ(req("q", "*:*", "rows", "100"),
+ "//*[@numFound='10']",
+ "count(//doc)=10", // exactly 10 docs in response
+ DONT_RETURN_FIELD); // no field in any doc other then 'id'
clearIndex();
assertU(commit());
}
public void testWhiteboxCreateFields() throws Exception {
- // TODO: we should have a "coverage" assert that we're looping over all the dynamic (point) fields in the schema
-
String[] typeNames = new String[]{"i", "l", "f", "d", "dt"};
- String[] suffixes = new String[]{"", "_dv", "_mv", "_mv_dv", "_ni", "_ni_dv", "_ni_dv_ns", "_ni_mv", "_ni_mv_dv", "_ni_ns", "_ni_ns_mv", "_dv_ns", "_ni_ns_dv", "_dv_ns_mv"};
+ String[] suffixes = new String[]{"", "_dv", "_mv", "_mv_dv", "_ni", "_ni_dv", "_ni_dv_ns", "_ni_dv_ns_mv", "_ni_mv", "_ni_mv_dv", "_ni_ns", "_ni_ns_mv", "_dv_ns", "_ni_ns_dv", "_dv_ns_mv"};
Class<?>[] expectedClasses = new Class[]{IntPoint.class, LongPoint.class, FloatPoint.class, DoublePoint.class, LongPoint.class};
Date dateToTest = new Date();
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/ce75eb62/solr/core/src/test/org/apache/solr/schema/TestUseDocValuesAsStored.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/schema/TestUseDocValuesAsStored.java b/solr/core/src/test/org/apache/solr/schema/TestUseDocValuesAsStored.java
index 48a3f22..9cababc 100644
--- a/solr/core/src/test/org/apache/solr/schema/TestUseDocValuesAsStored.java
+++ b/solr/core/src/test/org/apache/solr/schema/TestUseDocValuesAsStored.java
@@ -250,6 +250,34 @@ public class TestUseDocValuesAsStored extends AbstractBadConfigTestBase {
+ "{'id':'myid6','test_s_dvo':'hello'}"
+ "]");
}
+
+ @Test
+ public void testUseDocValuesAsStoredFalse() throws Exception {
+ SchemaField sf = h.getCore().getLatestSchema().getField("nonstored_dv_str");
+ assertNotNull(sf);
+ assertTrue(sf.hasDocValues());
+ assertFalse(sf.useDocValuesAsStored());
+ assertFalse(sf.stored());
+ assertU(adoc("id", "myid", "nonstored_dv_str", "dont see me"));
+ assertU(commit());
+
+ assertJQ(req("q", "id:myid"),
+ "/response/docs==["
+ + "{'id':'myid'}"
+ + "]");
+ assertJQ(req("q", "id:myid", "fl", "*"),
+ "/response/docs==["
+ + "{'id':'myid'}"
+ + "]");
+ assertJQ(req("q", "id:myid", "fl", "id,nonstored_dv_*"),
+ "/response/docs==["
+ + "{'id':'myid'}"
+ + "]");
+ assertJQ(req("q", "id:myid", "fl", "id,nonstored_dv_str"),
+ "/response/docs==["
+ + "{'id':'myid','nonstored_dv_str':'dont see me'}"
+ + "]");
+ }
public void testManagedSchema() throws Exception {
IndexSchema oldSchema = h.getCore().getLatestSchema();