SOLR-2039: Multivalued fields with dynamic names does not work properly with DIH

(cherry picked from commit b8d9647)
This commit is contained in:
Shalin Shekhar Mangar 2016-10-26 11:02:10 +05:30
parent de360d62cc
commit 279647a303
3 changed files with 28 additions and 0 deletions

View File

@ -177,6 +177,9 @@ Bug Fixes
* SOLR-9536: OldBackupDirectory timestamp field needs to be initialized to avoid NPE.
(Hrishikesh Gadre, hossman via Mark Miller)
* SOLR-2039: Multivalued fields with dynamic names does not work properly with DIH.
(K A, ruslan.shv, Cao Manh Dat via shalin)
Optimizations
----------------------

View File

@ -501,7 +501,9 @@ public class DocBuilder {
doc.addChildDocument(childDoc);
} else {
handleSpecialCommands(arow, doc);
vr.addNamespace(epw.getEntity().getName(), arow);
addFields(epw.getEntity(), doc, arow, vr);
vr.removeNamespace(epw.getEntity().getName());
}
}
if (epw.getEntity().getChildren() != null) {

View File

@ -115,6 +115,20 @@ public class TestDocBuilder2 extends AbstractDataImportHandlerTestCase {
assertQ(req("desc:ApacheSolr"), "//*[@numFound='1']");
}
@Test
@SuppressWarnings("unchecked")
public void testDynamicFieldNames() throws Exception {
List rows = new ArrayList();
rows.add(createMap("mypk", "101", "text", "ApacheSolr"));
MockDataSource.setIterator("select * from x", rows.iterator());
LocalSolrQueryRequest request = lrf.makeRequest("command", "full-import",
"debug", "on", "clean", "true", "commit", "true",
"dataConfig", dataConfigWithDynamicFieldNames);
h.query("/dataimport", request);
assertQ(req("id:101"), "//*[@numFound='1']", "//*[@name='101_s']");
}
@Test
@SuppressWarnings("unchecked")
public void testRequestParamsAsFieldName() throws Exception {
@ -398,6 +412,15 @@ public class TestDocBuilder2 extends AbstractDataImportHandlerTestCase {
" </document>\n" +
"</dataConfig>";
private final String dataConfigWithDynamicFieldNames = "<dataConfig><dataSource type=\"MockDataSource\"/>\n" +
" <document>\n" +
" <entity name=\"books\" query=\"select * from x\">\n" +
" <field column=\"mypk\" name=\"id\" />\n" +
" <field column=\"text\" name=\"${books.mypk}_s\" />\n" +
" </entity>\n" +
" </document>\n" +
"</dataConfig>";
private final String dataConfigFileList = "<dataConfig>\n" +
"\t<document>\n" +
"\t\t<entity name=\"x\" processor=\"FileListEntityProcessor\" \n" +