SOLR-2413: Support for returning multi-valued fields w/o <arr> tag in the XMLResponseWriter was removed. XMLResponseWriter only no longer work with values less then 2.2

Replaced "version" string with CommonParams.VERSION where possible

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1079963 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Ryan McKinley 2011-03-09 19:48:33 +00:00
parent 9ce62b7c07
commit e066a7e911
14 changed files with 104 additions and 133 deletions

View File

@ -184,6 +184,11 @@ Other Changes
and load it back on init. This means that large tries don't have to be
rebuilt on every commit or core reload. (ab)
* SOLR-2413: Support for returning multi-valued fields w/o <arr> tag
in the XMLResponseWriter was removed. XMLResponseWriter only
no longer work with values less then 2.2 (ryan)
Documentation
----------------------

View File

@ -19,6 +19,7 @@ package org.apache.solr.response;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.XML;
@ -76,9 +77,13 @@ public final class XMLWriter extends TextResponseWriter {
public XMLWriter(Writer writer, SolrQueryRequest req, SolrQueryResponse rsp) {
super(writer, req, rsp);
String version = req.getParams().get("version");
String version = req.getParams().get(CommonParams.VERSION);
float ver = version==null? CURRENT_VERSION : Float.parseFloat(version);
this.version = (int)(ver*1000);
if( this.version < 2200 ) {
throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,
"XMLWriter does not support version: "+version );
}
}
@ -110,28 +115,6 @@ public final class XMLWriter extends TextResponseWriter {
int sz = lst.size();
int start=0;
// special case the response header if the version is 2.1 or less
if (version<=2100 && sz>0) {
Object header = lst.getVal(0);
if (header instanceof NamedList && "responseHeader".equals(lst.getName(0))) {
writer.write("<responseHeader>");
incLevel();
NamedList nl = (NamedList)header;
for (int i=0; i<nl.size(); i++) {
String name = nl.getName(i);
Object val = nl.getVal(i);
if ("status".equals(name) || "QTime".equals(name)) {
writePrim(name,null,val.toString(),false);
} else {
writeVal(name,val);
}
}
decLevel();
writer.write("</responseHeader>");
start=1;
}
}
for (int i=start; i<sz; i++) {
writeVal(lst.getName(i),lst.getVal(i));
}
@ -248,7 +231,7 @@ public final class XMLWriter extends TextResponseWriter {
}
if (fidx1+1 == fidx2) {
// single field value
if (version>=2100 && sf.multiValued()) {
if (sf.multiValued()) {
startTag("arr",fname,false);
doIndent=false;
sf.write(this, null, f1);
@ -301,7 +284,7 @@ public final class XMLWriter extends TextResponseWriter {
} else {
// single valued... figure out if we should put <arr> tags around it anyway
SchemaField sf = schema.getFieldOrNull(fname);
if (version>=2100 && sf!=null && sf.multiValued()) {
if (sf!=null && sf.multiValued()) {
startTag("arr",fname,false);
doIndent=false;
writeVal(fname, val);

View File

@ -100,7 +100,7 @@ public class BasicFunctionalityTest extends SolrTestCaseJ4 {
@Test
public void testIgnoredFields() throws Exception {
lrf.args.put("version","2.0");
lrf.args.put(CommonParams.VERSION,"2.2");
assertU("adding doc with ignored field",
adoc("id", "42", "foo_ignored", "blah blah"));
assertU("commit",
@ -123,7 +123,7 @@ public class BasicFunctionalityTest extends SolrTestCaseJ4 {
assertEquals("Mergefactor was not picked up", ((LogMergePolicy) writer.getConfig().getMergePolicy()).getMergeFactor(), 8);
writer.close();
lrf.args.put("version","2.0");
lrf.args.put(CommonParams.VERSION,"2.2");
assertQ("test query on empty index",
req("qlkciyopsbgzyvkylsjhchghjrdf")
,"//result[@numFound='0']"
@ -445,7 +445,7 @@ public class BasicFunctionalityTest extends SolrTestCaseJ4 {
@Test
public void testDefaultFieldValues() {
clearIndex();
lrf.args.put("version","2.1");
lrf.args.put(CommonParams.VERSION,"2.2");
assertU(adoc("id", "4055",
"subject", "Hoss the Hoss man Hostetter"));
assertU(adoc("id", "4056",

View File

@ -17,6 +17,7 @@
package org.apache.solr;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.request.*;
import org.junit.BeforeClass;
import org.junit.Test;
@ -42,7 +43,7 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {
// these may be reused by things that need a special query
SolrQueryRequest req = null;
Map<String,String> args = new HashMap<String,String>();
lrf.args.put("version","2.0");
lrf.args.put(CommonParams.VERSION,"2.2");
lrf.args.put("defType","lucenePlusSort");
// compact the index, keep things from getting out of hand
@ -133,7 +134,6 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {
,"//*[@start='0']"
);
args = new HashMap<String,String>();
args.put("version","2.0");
req = new LocalSolrQueryRequest(h.getCore(), "val_s:[a TO z]",
"standard", 2, 5 , args);
assertQ(req
@ -143,7 +143,6 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {
,"//*[@start='2']"
);
args = new HashMap<String,String>();
args.put("version","2.0");
req = new LocalSolrQueryRequest(h.getCore(), "val_s:[a TO z]",
"standard", 3, 5 , args);
assertQ(req
@ -151,7 +150,6 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {
,"*[count(//doc)=0]"
);
args = new HashMap<String,String>();
args.put("version","2.0");
req = new LocalSolrQueryRequest(h.getCore(), "val_s:[a TO z]",
"standard", 4, 5 , args);
assertQ(req
@ -159,7 +157,6 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {
,"*[count(//doc)=0]"
);
args = new HashMap<String,String>();
args.put("version","2.0");
req = new LocalSolrQueryRequest(h.getCore(), "val_s:[a TO z]",
"standard", 25, 5 , args);
assertQ(req
@ -167,7 +164,6 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {
,"*[count(//doc)=0]"
);
args = new HashMap<String,String>();
args.put("version","2.0");
req = new LocalSolrQueryRequest(h.getCore(), "val_s:[a TO z]",
"standard", 0, 1 , args);
assertQ(req
@ -176,7 +172,6 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {
,"*//doc[1]/str[.='apple']"
);
args = new HashMap<String,String>();
args.put("version","2.0");
req = new LocalSolrQueryRequest(h.getCore(), "val_s:[a TO z]",
"standard", 0, 2 , args);
assertQ(req
@ -185,7 +180,6 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {
,"*//doc[2]/str[.='banana']"
);
args = new HashMap<String,String>();
args.put("version","2.0");
req = new LocalSolrQueryRequest(h.getCore(), "val_s:[a TO z]",
"standard", 1, 1 , args);
assertQ(req
@ -194,7 +188,6 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {
,"*//doc[1]/str[.='banana']"
);
args = new HashMap<String,String>();
args.put("version","2.0");
req = new LocalSolrQueryRequest(h.getCore(), "val_s:[a TO z]",
"standard", 3, 1 , args);
assertQ(req
@ -202,7 +195,6 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {
,"*[count(//doc)=0]"
);
args = new HashMap<String,String>();
args.put("version","2.0");
req = new LocalSolrQueryRequest(h.getCore(), "val_s:[a TO z]",
"standard", 4, 1 , args);
assertQ(req
@ -210,7 +202,6 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {
,"*[count(//doc)=0]"
);
args = new HashMap<String,String>();
args.put("version","2.0");
req = new LocalSolrQueryRequest(h.getCore(), "val_s:[a TO z]",
"standard", 1, 0 , args);
assertQ(req
@ -218,7 +209,6 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {
,"*[count(//doc)=0]"
);
args = new HashMap<String,String>();
args.put("version","2.0");
req = new LocalSolrQueryRequest(h.getCore(), "val_s:[a TO z]",
"standard", 0, 0 , args);
assertQ(req
@ -226,7 +216,6 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {
,"*[count(//doc)=0]"
);
args = new HashMap<String,String>();
args.put("version","2.0");
args.put("defType","lucenePlusSort");
req = new LocalSolrQueryRequest(h.getCore(), "val_s:[a TO z];val_s1 asc",
"standard", 0, 0 , args);
@ -235,7 +224,6 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {
,"*[count(//doc)=0]"
);
args = new HashMap<String,String>();
args.put("version","2.0");
args.put("defType","lucenePlusSort");
req = new LocalSolrQueryRequest(h.getCore(), "val_s:[a TO z];val_s1 desc",
"standard", 0, 0 , args);
@ -480,13 +468,13 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {
assertQ(req("id:44")
,"*[count(//doc/*)>=3] "
,"//int[@name='gack_i'][.='51778'] "
,"//str[@name='t_name'][.='cats']"
,"//arr[@name='gack_i']/int[.='51778'] "
,"//arr[@name='t_name']/str[.='cats']"
);
// now test if we can query by a dynamic field (requires analyzer support)
assertQ(req("t_name:cat")
,"//str[@name='t_name' and .='cats']"
,"//arr[@name='t_name' and .='cats']/str"
);
// check that deleteByQuery works for dynamic fields
@ -501,8 +489,8 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {
assertU("<add><doc><field name=\"id\">44</field><field name=\"xaa\">mystr</field><field name=\"xaaa\">12321</field></doc></add>");
assertU("<commit/>");
assertQ(req("id:44")
,"//str[@name='xaa'][.='mystr'] "
,"//int[@name='xaaa'][.='12321']"
,"//arr[@name='xaa'][.='mystr']/str "
,"//arr[@name='xaaa'][.='12321']/int"
);
@ -761,28 +749,28 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {
);
assertQ(req("id_i:[1000 TO 1010]; a_i1 asc,b_si desc")
,"*[count(//doc)=7] "
,"//doc[3]/int[.='100'] "
,"//doc[4]/int[.='50'] "
,"//doc[5]/int[.='1000']"
,"//doc[3]/int[@name='b_si' and .='100'] "
,"//doc[4]/int[@name='b_si' and .='50'] "
,"//doc[5]/arr[@name='id_i' and .='1000']"
);
assertQ(req("id_i:[1000 TO 1010]; a_i1 asc,b_si asc")
,"*[count(//doc)=7] "
,"//doc[3]/int[.='50'] "
,"//doc[4]/int[.='100'] "
,"//doc[5]/int[.='1000']"
,"//doc[3]/int[@name='b_si' and .='50'] "
,"//doc[4]/int[@name='b_si' and .='100'] "
,"//doc[5]/arr[@name='id_i' and .='1000']"
);
// nullfirst tests
assertQ(req("id_i:[1000 TO 1002]; nullfirst asc")
,"*[count(//doc)=3] "
,"//doc[1]/int[.='1002']"
,"//doc[2]/int[.='1001'] "
,"//doc[3]/int[.='1000']"
,"//doc[1]/arr[@name='id_i' and .='1002']"
,"//doc[2]/arr[@name='id_i' and .='1001'] "
,"//doc[3]/arr[@name='id_i' and .='1000']"
);
assertQ(req("id_i:[1000 TO 1002]; nullfirst desc")
,"*[count(//doc)=3] "
,"//doc[1]/int[.='1002']"
,"//doc[2]/int[.='1000'] "
,"//doc[3]/int[.='1001']"
,"//doc[1]/arr[@name='id_i' and .='1002']"
,"//doc[2]/arr[@name='id_i' and .='1000'] "
,"//doc[3]/arr[@name='id_i' and .='1001']"
);
ignoreException("shouldbeunindexed");
@ -1126,7 +1114,6 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {
assertQ(req("id:44")
);
args = new HashMap<String,String>();
args.put("version","2.0");
args.put("fl","fname_s,arr_f ");
req = new LocalSolrQueryRequest(h.getCore(), "id:44",
"standard", 0, 10, args);
@ -1135,7 +1122,6 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {
,"//float[.='1.4142135']"
);
args = new HashMap<String,String>();
args.put("version","2.0");
args.put("fl"," ");
req = new LocalSolrQueryRequest(h.getCore(), "id:44",
"standard", 0, 10, args);
@ -1147,7 +1133,6 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {
// test addition of score field
args = new HashMap<String,String>();
args.put("version","2.0");
args.put("fl","score ");
req = new LocalSolrQueryRequest(h.getCore(), "id:44",
"standard", 0, 10, args);
@ -1158,7 +1143,6 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {
,"*[count(//doc/*)>=13]"
);
args = new HashMap<String,String>();
args.put("version","2.0");
args.put("fl","*,score ");
req = new LocalSolrQueryRequest(h.getCore(), "id:44",
"standard", 0, 10, args);
@ -1169,7 +1153,6 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {
,"*[count(//doc/*)>=13]"
);
args = new HashMap<String,String>();
args.put("version","2.0");
args.put("fl","* ");
req = new LocalSolrQueryRequest(h.getCore(), "id:44",
"standard", 0, 10, args);
@ -1182,7 +1165,6 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {
// test maxScore
args = new HashMap<String,String>();
args.put("version","2.0");
args.put("fl","score ");
req = new LocalSolrQueryRequest(h.getCore(), "id:44",
"standard", 0, 10, args);
@ -1190,7 +1172,6 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {
,"//result[@maxScore>0]"
);
args = new HashMap<String,String>();
args.put("version","2.0");
args.put("fl","score ");
args.put("defType","lucenePlusSort");
req = new LocalSolrQueryRequest(h.getCore(), "id:44;id desc;",
@ -1199,7 +1180,6 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {
,"//result[@maxScore>0]"
);
args = new HashMap<String,String>();
args.put("version","2.0");
args.put("fl","score ");
args.put("defType","lucenePlusSort");
req = new LocalSolrQueryRequest(h.getCore(), "id:44;",
@ -1208,7 +1188,6 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {
,"//@maxScore = //doc/float[@name='score']"
);
args = new HashMap<String,String>();
args.put("version","2.0");
args.put("fl","score ");
args.put("defType","lucenePlusSort");
req = new LocalSolrQueryRequest(h.getCore(), "id:44;id desc;",
@ -1217,7 +1196,6 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {
,"//@maxScore = //doc/float[@name='score']"
);
args = new HashMap<String,String>();
args.put("version","2.0");
args.put("fl","score");
args.put("defType","lucenePlusSort");
req = new LocalSolrQueryRequest(h.getCore(), "id:44;id desc;",

View File

@ -32,7 +32,7 @@ public class DisMaxRequestHandlerTest extends SolrTestCaseJ4 {
initCore("solrconfig.xml","schema.xml");
lrf = h.getRequestFactory
("dismax", 0, 20,
"version","2.0",
CommonParams.VERSION,"2.2",
"facet", "true",
"facet.field","t_s"
);
@ -94,7 +94,7 @@ public class DisMaxRequestHandlerTest extends SolrTestCaseJ4 {
assertQ("multi qf",
req("q", "cool"
,"qt", qt
,"version", "2.0"
,CommonParams.VERSION, "2.2"
,"qf", "subject"
,"qf", "features_t"
)
@ -104,7 +104,7 @@ public class DisMaxRequestHandlerTest extends SolrTestCaseJ4 {
assertQ("boost query",
req("q", "cool stuff"
,"qt", qt
,"version", "2.0"
,CommonParams.VERSION, "2.2"
,"bq", "subject:hell^400"
)
,"//*[@numFound='3']"
@ -116,7 +116,7 @@ public class DisMaxRequestHandlerTest extends SolrTestCaseJ4 {
assertQ("multi boost query",
req("q", "cool stuff"
,"qt", qt
,"version", "2.0"
,CommonParams.VERSION, "2.2"
,"bq", "subject:hell^400"
,"bq", "subject:cool^4"
, CommonParams.DEBUG_QUERY, "true"
@ -176,7 +176,7 @@ public class DisMaxRequestHandlerTest extends SolrTestCaseJ4 {
Pattern p_bool = Pattern.compile("\\(subject:hell\\s*subject:cool\\)");
String resp = h.query(req("q", "cool stuff"
,"qt", "dismax"
,"version", "2.0"
,CommonParams.VERSION, "2.2"
,"bq", "subject:hell OR subject:cool"
,CommonParams.DEBUG_QUERY, "true"
));
@ -185,7 +185,7 @@ public class DisMaxRequestHandlerTest extends SolrTestCaseJ4 {
resp = h.query(req("q", "cool stuff"
,"qt", "dismax"
,"version", "2.0"
,CommonParams.VERSION, "2.2"
,"bq", "subject:hell OR subject:cool"
,"bq",""
,CommonParams.DEBUG_QUERY, "true"

View File

@ -17,6 +17,7 @@
package org.apache.solr;
import org.apache.solr.common.params.CommonParams;
import org.junit.BeforeClass;
import org.junit.Test;
@ -34,7 +35,7 @@ public class EchoParamsTest extends SolrTestCaseJ4 {
@Test
public void testDefaultEchoParams() {
lrf.args.put("wt", "xml");
lrf.args.put("version", "2.2");
lrf.args.put(CommonParams.VERSION, "2.2");
assertQ(req("foo"),HEADER_XPATH + "/int[@name='status']");
assertQ(req("foo"),"not(//lst[@name='params'])");
}
@ -42,7 +43,7 @@ public class EchoParamsTest extends SolrTestCaseJ4 {
@Test
public void testDefaultEchoParamsDefaultVersion() {
lrf.args.put("wt", "xml");
lrf.args.remove("version");
lrf.args.remove(CommonParams.VERSION);
assertQ(req("foo"),HEADER_XPATH + "/int[@name='status']");
assertQ(req("foo"),"not(//lst[@name='params'])");
}
@ -50,7 +51,7 @@ public class EchoParamsTest extends SolrTestCaseJ4 {
@Test
public void testExplicitEchoParams() {
lrf.args.put("wt", "xml");
lrf.args.put("version", "2.2");
lrf.args.put(CommonParams.VERSION, "2.2");
lrf.args.put("echoParams", "explicit");
assertQ(req("foo"),HEADER_XPATH + "/int[@name='status']");
assertQ(req("foo"),HEADER_XPATH + "/lst[@name='params']");
@ -61,7 +62,7 @@ public class EchoParamsTest extends SolrTestCaseJ4 {
public void testAllEchoParams() {
lrf = h.getRequestFactory
("crazy_custom_qt", 0, 20,
"version","2.2",
CommonParams.VERSION,"2.2",
"wt","xml",
"echoParams", "all",
"echoHandler","true"

View File

@ -17,6 +17,7 @@
package org.apache.solr;
import org.apache.solr.common.params.CommonParams;
import org.junit.BeforeClass;
import org.junit.Test;
@ -44,7 +45,7 @@ public class MinimalSchemaTest extends SolrTestCaseJ4 {
assertNull("UniqueKey Field isn't null",
h.getCore().getSchema().getUniqueKeyField());
lrf.args.put("version","2.0");
lrf.args.put(CommonParams.VERSION,"2.2");
assertNull("Simple assertion that adding a document works", h.validateUpdate(
adoc("id", "4055",

View File

@ -20,6 +20,7 @@ package org.apache.solr;
import java.io.IOException;
import java.io.Writer;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.response.QueryResponseWriter;
@ -42,25 +43,21 @@ public class OutputWriterTest extends SolrTestCaseJ4 {
}
/** responseHeader has changed in SOLR-59, check old and new variants */
/**
* responseHeader has changed in SOLR-59, check old and new variants,
* In SOLR-2413, we removed support for the deprecated versions
*/
@Test
public void testSOLR59responseHeaderVersions() {
// default version is 2.2, with "new" responseHeader
lrf.args.remove("version");
lrf.args.remove(CommonParams.VERSION);
lrf.args.put("wt", "standard");
assertQ(req("foo"), "/response/lst[@name='responseHeader']/int[@name='status'][.='0']");
lrf.args.remove("wt");
assertQ(req("foo"), "/response/lst[@name='responseHeader']/int[@name='QTime']");
// version=2.1 reverts to old responseHeader
lrf.args.put("version", "2.1");
lrf.args.put("wt", "standard");
assertQ(req("foo"), "/response/responseHeader/status[.='0']");
lrf.args.remove("wt");
assertQ(req("foo"), "/response/responseHeader/QTime");
// and explicit 2.2 works as default
lrf.args.put("version", "2.2");
//lrf.args.put("version", "2.2");
lrf.args.put("wt", "standard");
assertQ(req("foo"), "/response/lst[@name='responseHeader']/int[@name='status'][.='0']");
lrf.args.remove("wt");

View File

@ -17,6 +17,7 @@
package org.apache.solr;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.request.*;
import org.apache.solr.util.*;
import org.junit.BeforeClass;
@ -46,7 +47,7 @@ public class SampleTest extends SolrTestCaseJ4 {
*/
@Test
public void testSimple() {
lrf.args.put("version","2.0");
lrf.args.put(CommonParams.VERSION,"2.2");
assertU("Simple assertion that adding a document works",
adoc("id", "4055",
"subject", "Hoss the Hoss man Hostetter"));
@ -70,7 +71,7 @@ public class SampleTest extends SolrTestCaseJ4 {
*/
@Test
public void testAdvanced() throws Exception {
lrf.args.put("version","2.0");
lrf.args.put(CommonParams.VERSION,"2.2");
assertU("less common case, a complex addition with options",
add(doc("id", "4059",
"subject", "Who Me?"),
@ -102,7 +103,7 @@ public class SampleTest extends SolrTestCaseJ4 {
* Note: the qt proves we are using our custom config...
*/
TestHarness.LocalRequestFactory l = h.getRequestFactory
("crazy_custom_qt",100,200,"version","2.1");
("crazy_custom_qt",100,200,CommonParams.VERSION,"2.2");
assertQ("how did i find Mack Daddy? ",
l.makeRequest( "Mack Daddy" )
,"//result[@numFound=0]"

View File

@ -26,6 +26,7 @@ import org.apache.noggit.ObjectBuilder;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.SolrInputField;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.XML;
@ -238,7 +239,7 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {
solrConfig,
getSchemaFile());
lrf = h.getRequestFactory
("standard",0,20,"version","2.2");
("standard",0,20,CommonParams.VERSION,"2.2");
}
log.info("####initCore end");
}

View File

@ -18,6 +18,7 @@ package org.apache.solr.cloud;
*/
import org.apache.lucene.index.LogMergePolicy;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.core.SolrCore;
import org.apache.solr.update.SolrIndexWriter;
@ -50,7 +51,7 @@ public class BasicZkTest extends AbstractZkTestCase {
assertEquals("Mergefactor was not picked up", ((LogMergePolicy)writer.getConfig().getMergePolicy()).getMergeFactor(), 8);
writer.close();
lrf.args.put("version", "2.0");
lrf.args.put(CommonParams.VERSION, "2.2");
assertQ("test query on empty index", req("qlkciyopsbgzyvkylsjhchghjrdf"),
"//result[@numFound='0']");

View File

@ -32,6 +32,7 @@ import org.apache.lucene.queryParser.ParseException;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.Version;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.util.AbstractSolrTestCase;
import org.apache.solr.util.TestHarness;
import org.junit.Test;
@ -56,7 +57,7 @@ public class TestArbitraryIndexDir extends AbstractSolrTestCase{
solrConfig,
"schema12.xml");
lrf = h.getRequestFactory
("standard",0,20,"version","2.2");
("standard",0,20,CommonParams.VERSION,"2.2");
}
@Override

View File

@ -19,6 +19,7 @@ package org.apache.solr.handler;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.request.LocalSolrQueryRequest;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.util.ContentStream;
import org.apache.solr.common.util.ContentStreamBase;
import org.junit.After;
@ -121,12 +122,12 @@ public class TestCSVLoader extends SolrTestCaseJ4 {
@Test
public void testCSV() throws Exception {
lrf.args.put("version","2.0");
lrf.args.put(CommonParams.VERSION,"2.2");
makeFile("id,str_s\n100,\"quoted\"\n101,\n102,\"\"\n103,");
loadLocal("stream.file",filename,"commit","true");
assertQ(req("id:[100 TO 110]"),"//*[@numFound='4']");
assertQ(req("id:100"),"//str[@name='str_s'][.='quoted']");
assertQ(req("id:100"),"//arr[@name='str_s']/str[.='quoted']");
assertQ(req("id:101"),"count(//str[@name='str_s'])=0");
// 102 is a quoted zero length field ,"", as opposed to ,,
// but we can't distinguish this case (and it's debateable
@ -154,7 +155,7 @@ public class TestCSVLoader extends SolrTestCaseJ4 {
// test global value mapping
loadLocal("stream.file",filename, "commit","true", "map","quoted:QUOTED");
assertQ(req("id:[100 TO 110]"),"//*[@numFound='4']");
assertQ(req("id:100"),"//str[@name='str_s'][.='QUOTED']");
assertQ(req("id:100"),"//arr[@name='str_s']/str[.='QUOTED']");
assertQ(req("id:101"),"count(//str[@name='str_s'])=0");
assertQ(req("id:102"),"count(//str[@name='str_s'])=0");
assertQ(req("id:103"),"count(//str[@name='str_s'])=0");
@ -167,39 +168,39 @@ public class TestCSVLoader extends SolrTestCaseJ4 {
// test value mapping from empty
loadLocal("stream.file",filename, "commit","true", "map",":EMPTY");
assertQ(req("id:[100 TO 110]"),"//*[@numFound='4']");
assertQ(req("id:100"),"//str[@name='str_s'][.='quoted']");
assertQ(req("id:101"),"//str[@name='str_s'][.='EMPTY']");
assertQ(req("id:102"),"//str[@name='str_s'][.='EMPTY']");
assertQ(req("id:103"),"//str[@name='str_s'][.='EMPTY']");
assertQ(req("id:100"),"//arr[@name='str_s']/str[.='quoted']");
assertQ(req("id:101"),"//arr[@name='str_s']/str[.='EMPTY']");
assertQ(req("id:102"),"//arr[@name='str_s']/str[.='EMPTY']");
assertQ(req("id:103"),"//arr[@name='str_s']/str[.='EMPTY']");
// test multiple map rules
loadLocal("stream.file",filename, "commit","true", "map",":EMPTY", "map","quoted:QUOTED");
assertQ(req("id:[100 TO 110]"),"//*[@numFound='4']");
assertQ(req("id:100"),"//str[@name='str_s'][.='QUOTED']");
assertQ(req("id:101"),"//str[@name='str_s'][.='EMPTY']");
assertQ(req("id:102"),"//str[@name='str_s'][.='EMPTY']");
assertQ(req("id:103"),"//str[@name='str_s'][.='EMPTY']");
assertQ(req("id:100"),"//arr[@name='str_s']/str[.='QUOTED']");
assertQ(req("id:101"),"//arr[@name='str_s']/str[.='EMPTY']");
assertQ(req("id:102"),"//arr[@name='str_s']/str[.='EMPTY']");
assertQ(req("id:103"),"//arr[@name='str_s']/str[.='EMPTY']");
// test indexing empty fields
loadLocal("stream.file",filename, "commit","true", "f.str_s.keepEmpty","true");
assertQ(req("id:[100 TO 110]"),"//*[@numFound='4']");
assertQ(req("id:100"),"//str[@name='str_s'][.='quoted']");
assertQ(req("id:101"),"//str[@name='str_s'][.='']");
assertQ(req("id:102"),"//str[@name='str_s'][.='']");
assertQ(req("id:103"),"//str[@name='str_s'][.='']");
assertQ(req("id:100"),"//arr[@name='str_s']/str[.='quoted']");
assertQ(req("id:101"),"//arr[@name='str_s']/str[.='']");
assertQ(req("id:102"),"//arr[@name='str_s']/str[.='']");
assertQ(req("id:103"),"//arr[@name='str_s']/str[.='']");
// test overriding the name of fields
loadLocal("stream.file",filename, "commit","true",
"fieldnames","id,my_s", "header","true",
"f.my_s.map",":EMPTY");
assertQ(req("id:[100 TO 110]"),"//*[@numFound='4']");
assertQ(req("id:100"),"//str[@name='my_s'][.='quoted']");
assertQ(req("id:101"),"count(//str[@name='str_s'])=0");
assertQ(req("id:102"),"count(//str[@name='str_s'])=0");
assertQ(req("id:103"),"count(//str[@name='str_s'])=0");
assertQ(req("id:101"),"//str[@name='my_s'][.='EMPTY']");
assertQ(req("id:102"),"//str[@name='my_s'][.='EMPTY']");
assertQ(req("id:103"),"//str[@name='my_s'][.='EMPTY']");
assertQ(req("id:100"),"//arr[@name='my_s']/str[.='quoted']");
assertQ(req("id:101"),"count(//arr[@name='str_s']/str)=0");
assertQ(req("id:102"),"count(//arr[@name='str_s']/str)=0");
assertQ(req("id:103"),"count(//arr[@name='str_s']/str)=0");
assertQ(req("id:101"),"//arr[@name='my_s']/str[.='EMPTY']");
assertQ(req("id:102"),"//arr[@name='my_s']/str[.='EMPTY']");
assertQ(req("id:103"),"//arr[@name='my_s']/str[.='EMPTY']");
// test that header in file was skipped
assertQ(req("id:id"),"//*[@numFound='0']");
@ -207,24 +208,24 @@ public class TestCSVLoader extends SolrTestCaseJ4 {
// test skipping a field via the "skip" parameter
loadLocal("stream.file",filename,"commit","true","keepEmpty","true","skip","str_s");
assertQ(req("id:[100 TO 110]"),"//*[@numFound='4']");
assertQ(req("id:[100 TO 110]"),"count(//str[@name='str_s'])=0");
assertQ(req("id:[100 TO 110]"),"count(//str[@name='str_s']/str)=0");
// test skipping a field by specifying an empty name
loadLocal("stream.file",filename,"commit","true","keepEmpty","true","fieldnames","id,");
assertQ(req("id:[100 TO 110]"),"//*[@numFound='4']");
assertQ(req("id:[100 TO 110]"),"count(//str[@name='str_s'])=0");
assertQ(req("id:[100 TO 110]"),"count(//str[@name='str_s']/str)=0");
// test loading file as if it didn't have a header
loadLocal("stream.file",filename, "commit","true",
"fieldnames","id,my_s", "header","false");
assertQ(req("id:id"),"//*[@numFound='1']");
assertQ(req("id:100"),"//str[@name='my_s'][.='quoted']");
assertQ(req("id:100"),"//arr[@name='my_s']/str[.='quoted']");
// test skipLines
loadLocal("stream.file",filename, "commit","true",
"fieldnames","id,my_s", "header","false", "skipLines","1");
assertQ(req("id:id"),"//*[@numFound='1']");
assertQ(req("id:100"),"//str[@name='my_s'][.='quoted']");
assertQ(req("id:100"),"//arr[@name='my_s']/str[.='quoted']");
// test multi-valued fields via field splitting w/ mapping of subvalues
@ -237,12 +238,12 @@ public class TestCSVLoader extends SolrTestCaseJ4 {
"f.str_s.map",":EMPTY",
"f.str_s.split","true");
assertQ(req("id:[100 TO 110]"),"//*[@numFound='4']");
assertQ(req("id:100"),"//str[@name='str_s'][.='quoted']");
assertQ(req("id:100"),"//arr[@name='str_s']/str[.='quoted']");
assertQ(req("id:101"),"//arr[@name='str_s']/str[1][.='a']");
assertQ(req("id:101"),"//arr[@name='str_s']/str[2][.='b']");
assertQ(req("id:101"),"//arr[@name='str_s']/str[3][.='c']");
assertQ(req("id:102"),"//arr[@name='str_s']/str[2][.='EMPTY']");
assertQ(req("id:103"),"//str[@name='str_s'][.='EMPTY']");
assertQ(req("id:103"),"//arr[@name='str_s']/str[.='EMPTY']");
// test alternate values for delimiters
@ -263,13 +264,13 @@ public class TestCSVLoader extends SolrTestCaseJ4 {
"f.str_s.encapsulator","'"
);
assertQ(req("id:[100 TO 110]"),"//*[@numFound='5']");
assertQ(req("id:100"),"//str[@name='str_s'][.='quoted']");
assertQ(req("id:100"),"//arr[@name='str_s']/str[.='quoted']");
assertQ(req("id:101"),"//arr[@name='str_s']/str[1][.='a']");
assertQ(req("id:101"),"//arr[@name='str_s']/str[2][.='b']");
assertQ(req("id:101"),"//arr[@name='str_s']/str[3][.='c']");
assertQ(req("id:102"),"//arr[@name='str_s']/str[2][.='EMPTY']");
assertQ(req("id:103"),"//str[@name='str_s'][.='EMPTY']");
assertQ(req("id:104"),"//str[@name='str_s'][.='a\\\\b']");
assertQ(req("id:103"),"//arr[@name='str_s']/str[.='EMPTY']");
assertQ(req("id:104"),"//arr[@name='str_s']/str[.='a\\\\b']");
// test no escaping + double encapsulator escaping by default
makeFile("id,str_s\n"
@ -279,9 +280,9 @@ public class TestCSVLoader extends SolrTestCaseJ4 {
);
loadLocal("stream.file",filename, "commit","true"
);
assertQ(req("id:100"),"//str[@name='str_s'][.='quoted \" \\ string']");
assertQ(req("id:101"),"//str[@name='str_s'][.='unquoted \"\" \\ string']");
assertQ(req("id:102"),"//str[@name='str_s'][.='end quote \\']");
assertQ(req("id:100"),"//arr[@name='str_s']/str[.='quoted \" \\ string']");
assertQ(req("id:101"),"//arr[@name='str_s']/str[.='unquoted \"\" \\ string']");
assertQ(req("id:102"),"//arr[@name='str_s']/str[.='end quote \\']");
// setting an escape should disable encapsulator
@ -292,8 +293,8 @@ public class TestCSVLoader extends SolrTestCaseJ4 {
loadLocal("stream.file",filename, "commit","true"
,"escape","\\"
);
assertQ(req("id:100"),"//str[@name='str_s'][.='\"quoted \"\" \" \\ string\"']");
assertQ(req("id:101"),"//str[@name='str_s'][.='unquoted \"\" \" , \\ string']");
assertQ(req("id:100"),"//arr[@name='str_s']/str[.='\"quoted \"\" \" \\ string\"']");
assertQ(req("id:101"),"//arr[@name='str_s']/str[.='unquoted \"\" \" , \\ string']");
}

View File

@ -25,6 +25,7 @@ import org.apache.solr.core.SolrConfig;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.SolrInputField;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.util.XML;
import org.apache.solr.request.*;
import org.apache.solr.util.TestHarness;
@ -132,7 +133,7 @@ public abstract class AbstractSolrTestCase extends LuceneTestCase {
solrConfig,
getSchemaFile());
lrf = h.getRequestFactory
("standard",0,20,"version","2.2");
("standard",0,20,CommonParams.VERSION,"2.2");
}
log.info("####SETUP_END " + getName());
}