SOLR-8276: Atomic updates and realtime-get do not work with non-stored docvalues

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1722009 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shalin Shekhar Mangar 2015-12-28 21:42:11 +00:00
parent d2058e1c29
commit ef103c674a
4 changed files with 71 additions and 3 deletions

View File

@ -317,6 +317,9 @@ Bug Fixes
* SOLR-8460: /analysis/field could throw exceptions for custom attributes. (David Smiley, Uwe Schindler)
* SOLR-8276: Atomic updates and realtime-get do not work with non-stored docvalues.
(Ishan Chattopadhyaya, yonik via shalin)
Other Changes
----------------------

View File

@ -341,6 +341,7 @@ public class RealTimeGetComponent extends SearchComponent
if (docid < 0) return null;
StoredDocument luceneDocument = searcher.doc(docid);
sid = toSolrInputDocument(luceneDocument, core.getLatestSchema());
searcher.decorateDocValueFields(sid, docid, searcher.getNonStoredDVs(false));
}
} finally {
if (searcherHolder != null) {
@ -358,7 +359,7 @@ public class RealTimeGetComponent extends SearchComponent
SchemaField sf = schema.getFieldOrNull(f.name());
Object val = null;
if (sf != null) {
if (!sf.stored() || schema.isCopyFieldTarget(sf)) continue;
if ((!sf.hasDocValues() && !sf.stored()) || schema.isCopyFieldTarget(sf)) continue;
val = sf.getType().toObject(f); // object or external string?
} else {
val = f.stringValue();

View File

@ -654,7 +654,14 @@
<dynamicField name="*_d_dv" type="double" indexed="true" stored="true" docValues="true"/>
<dynamicField name="*_dt_dv" type="date" indexed="true" stored="true" docValues="true"/>
<dynamicField name="*_f1_dv" type="float" indexed="true" stored="true" docValues="true" multiValued="false"/>
<!-- Non-stored, DocValues=true -->
<dynamicField name="*_i_dvo" multiValued="false" type="int" docValues="true" indexed="true" stored="false" useDocValuesAsStored="true"/>
<dynamicField name="*_d_dvo" multiValued="false" type="double" docValues="true" indexed="true" stored="false" useDocValuesAsStored="true"/>
<dynamicField name="*_s_dvo" multiValued="false" type="string" docValues="true" indexed="true" stored="false" useDocValuesAsStored="true"/>
<dynamicField name="*_ii_dvo" multiValued="true" type="int" docValues="true" indexed="true" stored="false" useDocValuesAsStored="true"/>
<dynamicField name="*_dd_dvo" multiValued="true" type="double" docValues="true" indexed="true" stored="false" useDocValuesAsStored="true"/>
</fields>
<defaultSearchField>text</defaultSearchField>

View File

@ -1009,7 +1009,64 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
}
}
@Test
public void testAtomicUpdatesOnNonStoredDocValues() throws Exception {
assertU(adoc(sdoc("id", 2, "title", "title2", "single_i_dvo", 100)));
assertU(adoc(sdoc("id", 3, "title", "title3", "single_d_dvo", 3.14)));
assertU(adoc(sdoc("id", 4, "single_s_dvo", "abc", "single_i_dvo", 1)));
assertU(commit());
assertU(adoc(sdoc("id", 2, "title", ImmutableMap.of("set", "newtitle2"),
"single_i_dvo", ImmutableMap.of("inc", 1))));
assertU(adoc(sdoc("id", 3, "title", ImmutableMap.of("set", "newtitle3"),
"single_d_dvo", ImmutableMap.of("inc", 1))));
assertU(adoc(sdoc("id", 4, "single_i_dvo", ImmutableMap.of("inc", 1))));
assertU(commit());
assertJQ(req("q", "id:2"),
"/response/docs/[0]/id==2",
"/response/docs/[0]/title/[0]=='newtitle2'",
"/response/docs/[0]/single_i_dvo==101");
assertJQ(req("q", "id:3"),
1e-4,
"/response/docs/[0]/id==3",
"/response/docs/[0]/title/[0]=='newtitle3'",
"/response/docs/[0]/single_d_dvo==4.14");
assertJQ(req("q", "id:4"),
1e-4,
"/response/docs/[0]/id==4",
"/response/docs/[0]/single_s_dvo=='abc'",
"/response/docs/[0]/single_i_dvo==2");
// test that non stored docvalues was carried forward for a non-docvalue update
assertU(adoc(sdoc("id", 3, "title", ImmutableMap.of("set", "newertitle3"))));
assertU(commit());
assertJQ(req("q", "id:3"),
1e-4,
"/response/docs/[0]/id==3",
"/response/docs/[0]/title/[0]=='newertitle3'",
"/response/docs/[0]/single_d_dvo==4.14");
}
@Test
public void testAtomicUpdatesOnNonStoredDocValuesMulti() throws Exception {
assertU(adoc(sdoc("id", 1, "title", "title1", "multi_ii_dvo", 100, "multi_ii_dvo", Integer.MAX_VALUE)));
assertU(commit());
assertU(adoc(sdoc("id", 1, "title", ImmutableMap.of("set", "newtitle1"))));
assertU(commit());
// test that non stored multivalued docvalues was carried forward for a non docvalues update
assertJQ(req("q", "id:1"),
"/response/docs/[0]/id==1",
"/response/docs/[0]/title/[0]=='newtitle1'",
"/response/docs/[0]/multi_ii_dvo/[0]==100",
"/response/docs/[0]/multi_ii_dvo/[1]==" + Integer.MAX_VALUE);
}
@Test
public void testInvalidOperation() {
SolrInputDocument doc;