You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ho...@apache.org on 2016/03/12 01:26:59 UTC
[18/50] [abbrv] lucene-solr git commit: SOLR-8813: Add test for
MultiValued fields being returned in the correct order
SOLR-8813: Add test for MultiValued fields being returned in the correct order
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/540e8010
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/540e8010
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/540e8010
Branch: refs/heads/jira/SOLR-445
Commit: 540e8010c32c600a4ec6b29f6236ba43b9d1afd6
Parents: dee8b5e
Author: Erick Erickson <er...@apache.org>
Authored: Wed Mar 9 11:40:44 2016 -0800
Committer: Erick Erickson <er...@apache.org>
Committed: Wed Mar 9 11:40:44 2016 -0800
----------------------------------------------------------------------
.../conf/schema-non-stored-docvalues.xml | 131 ++++++++++---------
.../solr/schema/TestUseDocValuesAsStored.java | 60 ++++++++-
2 files changed, 126 insertions(+), 65 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/540e8010/solr/core/src/test-files/solr/collection1/conf/schema-non-stored-docvalues.xml
----------------------------------------------------------------------
diff --git a/solr/core/src/test-files/solr/collection1/conf/schema-non-stored-docvalues.xml b/solr/core/src/test-files/solr/collection1/conf/schema-non-stored-docvalues.xml
index aab4da4..f700e60 100644
--- a/solr/core/src/test-files/solr/collection1/conf/schema-non-stored-docvalues.xml
+++ b/solr/core/src/test-files/solr/collection1/conf/schema-non-stored-docvalues.xml
@@ -35,70 +35,73 @@
1.6: useDocValuesAsStored defaults to true.
-->
- <types>
-
- <!-- field type definitions... note that the "name" attribute is
- just a label to be used by field definitions. The "class"
- attribute and any other attributes determine the real type and
- behavior of the fieldType.
- -->
-
- <fieldType name="int" class="solr.TrieIntField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
- <fieldType name="float" class="solr.TrieFloatField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
- <fieldType name="long" class="solr.TrieLongField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
- <fieldType name="double" class="solr.TrieDoubleField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
-
-
- <fieldType name="tint" class="solr.TrieIntField" precisionStep="8" omitNorms="true" positionIncrementGap="0"/>
- <fieldType name="tfloat" class="solr.TrieFloatField" precisionStep="8" omitNorms="true" positionIncrementGap="0"/>
- <fieldType name="tlong" class="solr.TrieLongField" precisionStep="8" omitNorms="true" positionIncrementGap="0"/>
- <fieldType name="tdouble" class="solr.TrieDoubleField" precisionStep="8" omitNorms="true" positionIncrementGap="0"/>
-
-
- <fieldType name="boolean" class="solr.BoolField" sortMissingLast="true"/>
- <fieldType name="string" class="solr.StrField" sortMissingLast="true"/>
-
- <!-- format for date is 1995-12-31T23:59:59.999Z and only the fractional
- seconds part (.999) is optional.
- -->
- <fieldType name="date" class="solr.TrieDateField" precisionStep="0"/>
- <fieldType name="tdate" class="solr.TrieDateField" precisionStep="6"/>
- <fieldType name="tdatedv" class="solr.TrieDateField" precisionStep="6" docValues="true"/>
- <fieldType name="enumField" class="solr.EnumField" enumsConfig="enumsConfig.xml" enumName="severity"/>
- </types>
-
- <fields>
- <field name="id" type="string" indexed="true" stored="true" multiValued="false" required="false"/>
-
- <field name="_version_" type="long" indexed="true" stored="true" docValues="true" multiValued="false"/>
-
- <field name="nonstored_dv_str" type="string" indexed="true" stored="false"
- docValues="true" useDocValuesAsStored="false" multiValued="false"/>
-
- <field name="test_nonstored_dv_str" type="string" indexed="true" stored="false" docValues="true" multiValued="false"/>
-
- <!-- single valued fields -->
- <field name="enum_dvo" type="enumField" indexed="true" stored="false" multiValued="false" docValues="true"/>
- <dynamicField name="*_s_dvo2" multiValued="false" type="string" docValues="true" indexed="false" stored="false"/>
- <dynamicField name="*_s_dv" multiValued="false" type="string" docValues="true" indexed="true" stored="true"/>
- <dynamicField name="*_s_dvo" multiValued="false" type="string" docValues="true" indexed="true" stored="false"/>
- <dynamicField name="*_i_dvo" multiValued="false" type="int" docValues="true" indexed="true" stored="false"/>
- <dynamicField name="*_f_dvo" multiValued="false" type="float" docValues="true" indexed="true" stored="false"/>
- <dynamicField name="*_d_dvo" multiValued="false" type="double" docValues="true" indexed="true" stored="false"/>
- <dynamicField name="*_l_dvo" multiValued="false" type="long" docValues="true" indexed="true" stored="false"/>
- <dynamicField name="*_dt_dvo" multiValued="false" type="date" docValues="true" indexed="true" stored="false"/>
-
- <!-- multi valued fields -->
- <field name="enums_dvo" type="enumField" indexed="true" stored="false" multiValued="true" docValues="true"/>
- <dynamicField name="*_ss_dvo2" multiValued="true" type="string" docValues="true" indexed="false" stored="false"/>
- <dynamicField name="*_ss_dv" multiValued="true" type="string" docValues="true" indexed="true" stored="true"/>
- <dynamicField name="*_ss_dvo" multiValued="true" type="string" docValues="true" indexed="true" stored="false"/>
- <dynamicField name="*_is_dvo" multiValued="true" type="int" docValues="true" indexed="true" stored="false"/>
- <dynamicField name="*_fs_dvo" multiValued="true" type="float" docValues="true" indexed="true" stored="false"/>
- <dynamicField name="*_ds_dvo" multiValued="true" type="double" docValues="true" indexed="true" stored="false"/>
- <dynamicField name="*_ls_dvo" multiValued="true" type="long" docValues="true" indexed="true" stored="false"/>
- <dynamicField name="*_dts_dvo" multiValued="true" type="date" docValues="true" indexed="true" stored="false"/>
- </fields>
+
+ <!-- field type definitions... note that the "name" attribute is
+ just a label to be used by field definitions. The "class"
+ attribute and any other attributes determine the real type and
+ behavior of the fieldType.
+ -->
+
+ <fieldType name="int" class="solr.TrieIntField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
+ <fieldType name="float" class="solr.TrieFloatField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
+ <fieldType name="long" class="solr.TrieLongField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
+ <fieldType name="double" class="solr.TrieDoubleField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
+
+
+ <fieldType name="tint" class="solr.TrieIntField" precisionStep="8" omitNorms="true" positionIncrementGap="0"/>
+ <fieldType name="tfloat" class="solr.TrieFloatField" precisionStep="8" omitNorms="true" positionIncrementGap="0"/>
+ <fieldType name="tlong" class="solr.TrieLongField" precisionStep="8" omitNorms="true" positionIncrementGap="0"/>
+ <fieldType name="tdouble" class="solr.TrieDoubleField" precisionStep="8" omitNorms="true" positionIncrementGap="0"/>
+
+
+ <fieldType name="boolean" class="solr.BoolField" sortMissingLast="true"/>
+ <fieldType name="string" class="solr.StrField" sortMissingLast="true"/>
+
+ <!-- format for date is 1995-12-31T23:59:59.999Z and only the fractional
+ seconds part (.999) is optional.
+ -->
+ <fieldType name="date" class="solr.TrieDateField" precisionStep="0"/>
+ <fieldType name="tdate" class="solr.TrieDateField" precisionStep="6"/>
+ <fieldType name="tdatedv" class="solr.TrieDateField" precisionStep="6" docValues="true"/>
+ <fieldType name="enumField" class="solr.EnumField" enumsConfig="enumsConfig.xml" enumName="severity"/>
+
+
+ <field name="id" type="string" indexed="true" stored="true" multiValued="false" required="false"/>
+
+ <field name="_version_" type="long" indexed="true" stored="true" docValues="true" multiValued="false"/>
+
+ <field name="nonstored_dv_str" type="string" indexed="true" stored="false"
+ docValues="true" useDocValuesAsStored="false" multiValued="false"/>
+
+ <field name="test_nonstored_dv_str" type="string" indexed="true" stored="false" docValues="true" multiValued="false"/>
+
+ <field name="test_mvt_dvt_st_str" type="string" indexed="true" multiValued="true" docValues="true" stored="true"/>
+ <field name="test_mvt_dvt_sf_str" type="string" indexed="true" multiValued="true" docValues="true" stored="false"/>
+ <field name="test_mvt_dvf_st_str" type="string" indexed="true" multiValued="true" docValues="false" stored="true"/>
+ <field name="test_mvt_dvu_st_str" type="string" indexed="true" multiValued="true" stored="true"/>
+
+ <!-- single valued fields -->
+ <field name="enum_dvo" type="enumField" indexed="true" stored="false" multiValued="false" docValues="true"/>
+ <dynamicField name="*_s_dvo2" multiValued="false" type="string" docValues="true" indexed="false" stored="false"/>
+ <dynamicField name="*_s_dv" multiValued="false" type="string" docValues="true" indexed="true" stored="true"/>
+ <dynamicField name="*_s_dvo" multiValued="false" type="string" docValues="true" indexed="true" stored="false"/>
+ <dynamicField name="*_i_dvo" multiValued="false" type="int" docValues="true" indexed="true" stored="false"/>
+ <dynamicField name="*_f_dvo" multiValued="false" type="float" docValues="true" indexed="true" stored="false"/>
+ <dynamicField name="*_d_dvo" multiValued="false" type="double" docValues="true" indexed="true" stored="false"/>
+ <dynamicField name="*_l_dvo" multiValued="false" type="long" docValues="true" indexed="true" stored="false"/>
+ <dynamicField name="*_dt_dvo" multiValued="false" type="date" docValues="true" indexed="true" stored="false"/>
+
+ <!-- multi valued fields -->
+ <field name="enums_dvo" type="enumField" indexed="true" stored="false" multiValued="true" docValues="true"/>
+ <dynamicField name="*_ss_dvo2" multiValued="true" type="string" docValues="true" indexed="false" stored="false"/>
+ <dynamicField name="*_ss_dv" multiValued="true" type="string" docValues="true" indexed="true" stored="true"/>
+ <dynamicField name="*_ss_dvo" multiValued="true" type="string" docValues="true" indexed="true" stored="false"/>
+ <dynamicField name="*_is_dvo" multiValued="true" type="int" docValues="true" indexed="true" stored="false"/>
+ <dynamicField name="*_fs_dvo" multiValued="true" type="float" docValues="true" indexed="true" stored="false"/>
+ <dynamicField name="*_ds_dvo" multiValued="true" type="double" docValues="true" indexed="true" stored="false"/>
+ <dynamicField name="*_ls_dvo" multiValued="true" type="long" docValues="true" indexed="true" stored="false"/>
+ <dynamicField name="*_dts_dvo" multiValued="true" type="date" docValues="true" indexed="true" stored="false"/>
+
<uniqueKey>id</uniqueKey>
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/540e8010/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 46f76ab..839121a 100644
--- a/solr/core/src/test/org/apache/solr/schema/TestUseDocValuesAsStored.java
+++ b/solr/core/src/test/org/apache/solr/schema/TestUseDocValuesAsStored.java
@@ -76,7 +76,7 @@ public class TestUseDocValuesAsStored extends AbstractBadConfigTestBase {
@Test
public void testOnEmptyIndex() throws Exception {
- assertU(delQ("*:*"));
+ clearIndex();
assertU(commit());
assertJQ(req("q", "*:*"), "/response/numFound==0");
assertJQ(req("q", "*:*", "fl", "*"), "/response/numFound==0");
@@ -238,4 +238,62 @@ public class TestUseDocValuesAsStored extends AbstractBadConfigTestBase {
assertQ(desc + ": " + fl, req("q", "*:*", "fl", fl), xpaths);
}
+
+ // See SOLR-8740 for a discussion. This test is here to make sure we consciously change behavior of multiValued
+ // fields given that we can now return docValues fields. The behavior we've guaranteed in the past is that if
+ // multiValued fields are stored, they're returned in the document in the order they were added.
+ // There are four new fieldTypes added:
+ // <field name="test_mvt_dvt_st_str" type="string" indexed="true" multiValued="true" docValues="true" stored="true"/>
+ // <field name="test_mvt_dvt_sf_str" type="string" indexed="true" multiValued="true" docValues="true" stored="false"/>
+ // <field name="test_mvt_dvf_st_str" type="string" indexed="true" multiValued="true" docValues="false" stored="true"/>
+ // <field name="test_mvt_dvu_st_str" type="string" indexed="true" multiValued="true" stored="true"/>
+ //
+ // If any of these tests break as a result of returning DocValues rather than stored values, make sure we reach some
+ // consensus that any breaks on back-compat are A Good Thing and that that behavior is carefully documented!
+
+ @Test
+ public void testMultivaluedOrdering() throws Exception {
+ clearIndex();
+
+ // multiValued=true, docValues=true, stored=true. Should return in original order
+ assertU(adoc("id", "1", "test_mvt_dvt_st_str", "cccc", "test_mvt_dvt_st_str", "aaaa", "test_mvt_dvt_st_str", "bbbb"));
+
+ // multiValued=true, docValues=true, stored=false. Should return in sorted order
+ assertU(adoc("id", "2", "test_mvt_dvt_sf_str", "cccc", "test_mvt_dvt_sf_str", "aaaa", "test_mvt_dvt_sf_str", "bbbb"));
+
+ // multiValued=true, docValues=false, stored=true. Should return in original order
+ assertU(adoc("id", "3", "test_mvt_dvf_st_str", "cccc", "test_mvt_dvf_st_str", "aaaa", "test_mvt_dvf_st_str", "bbbb"));
+
+ // multiValued=true, docValues=not specified, stored=true. Should return in original order
+ assertU(adoc("id", "4", "test_mvt_dvu_st_str", "cccc", "test_mvt_dvu_st_str", "aaaa", "test_mvt_dvu_st_str", "bbbb"));
+
+ assertU(commit());
+
+ assertJQ(req("q", "id:1", "fl", "test_mvt_dvt_st_str"),
+ "/response/docs/[0]/test_mvt_dvt_st_str/[0]==cccc",
+ "/response/docs/[0]/test_mvt_dvt_st_str/[1]==aaaa",
+ "/response/docs/[0]/test_mvt_dvt_st_str/[2]==bbbb");
+
+ // Currently, this test fails since stored=false. When SOLR-8740 is committed, it should not throw an exception
+ // and should succeed, returning the field in sorted order.
+ try {
+ assertJQ(req("q", "id:2", "fl", "test_mvt_dvt_sf_str"),
+ "/response/docs/[0]/test_mvt_dvt_sf_str/[0]==aaaa",
+ "/response/docs/[0]/test_mvt_dvt_sf_str/[1]==bbbb",
+ "/response/docs/[0]/test_mvt_dvt_sf_str/[2]==cccc");
+ } catch (Exception e) {
+ // do nothing until SOLR-8740 is committed. At that point this should not throw an exception.
+ // NOTE: I think the test is correct after 8740 so just remove the try/catch
+ }
+ assertJQ(req("q", "id:3", "fl", "test_mvt_dvf_st_str"),
+ "/response/docs/[0]/test_mvt_dvf_st_str/[0]==cccc",
+ "/response/docs/[0]/test_mvt_dvf_st_str/[1]==aaaa",
+ "/response/docs/[0]/test_mvt_dvf_st_str/[2]==bbbb");
+
+ assertJQ(req("q", "id:4", "fl", "test_mvt_dvu_st_str"),
+ "/response/docs/[0]/test_mvt_dvu_st_str/[0]==cccc",
+ "/response/docs/[0]/test_mvt_dvu_st_str/[1]==aaaa",
+ "/response/docs/[0]/test_mvt_dvu_st_str/[2]==bbbb");
+
+ }
}