SOLR-823 -- Request parameter variables ${dataimporter.request.xxx} are not resolved

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@707287 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shalin Shekhar Mangar 2008-10-23 06:16:45 +00:00
parent 325594751f
commit ca6e3f100f
3 changed files with 31 additions and 2 deletions

View File

@ -34,6 +34,9 @@ Bug Fixes
1. SOLR-800: Deep copy collections to avoid ConcurrentModificationException in XPathEntityprocessor while streaming
(Kyle Morrison, Noble Paul via shalin)
2. SOLR-823: Request parameter variables ${dataimporter.request.xxx} are not resolved
(Mck SembWever, Noble Paul, shalin)
Documentation
----------------------

View File

@ -85,7 +85,7 @@ public class DocBuilder {
indexerNamespace.put(LAST_INDEX_TIME, DataImporter.DATE_TIME_FORMAT
.format(context.getLastIndexTime()));
indexerNamespace.put(INDEX_START_TIME, context.getIndexStartTime());
indexerNamespace.put("request", requestParameters);
indexerNamespace.put("request", requestParameters.requestParams);
indexerNamespace.put("defaults", defaultVariables);
indexerNamespace.put("functions", EvaluatorBag.getFunctionsNamespace(resolver,
dataImporter.getConfig().evaluators));

View File

@ -20,6 +20,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.Assert;
import org.apache.solr.request.LocalSolrQueryRequest;
import java.util.ArrayList;
import java.util.List;
@ -67,6 +68,21 @@ public class TestDocBuilder2 extends AbstractDataImportHandlerTest {
assertQ(req("id:1"), "//*[@numFound='1']");
}
@Test
@SuppressWarnings("unchecked")
public void testRequestParamsAsVariable() throws Exception {
List rows = new ArrayList();
rows.add(createMap("id", "101", "desc", "ApacheSolr"));
MockDataSource.setIterator("select * from books where category='search'", rows.iterator());
LocalSolrQueryRequest request = lrf.makeRequest("command", "full-import",
"debug", "on", "clean", "true", "commit", "true",
"category", "search",
"dataConfig", requestParamAsVariable);
h.query("/dataimport", request);
assertQ(req("desc:ApacheSolr"), "//*[@numFound='1']");
}
@Test
@SuppressWarnings("unchecked")
public void testContext() throws Exception {
@ -88,4 +104,14 @@ public class TestDocBuilder2 extends AbstractDataImportHandlerTest {
}
private final String requestParamAsVariable = "<dataConfig>\n" +
" <dataSource type=\"MockDataSource\" />\n" +
" <document>\n" +
" <entity name=\"books\" query=\"select * from books where category='${dataimporter.request.category}'\">\n" +
" <field column=\"id\" />\n" +
" <field column=\"desc\" />\n" +
" </entity>\n" +
" </document>\n" +
"</dataConfig>";
}