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 and load it back on init. This means that large tries don't have to be
rebuilt on every commit or core reload. (ab) 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 Documentation
---------------------- ----------------------

View File

@ -19,6 +19,7 @@ package org.apache.solr.response;
import org.apache.solr.common.SolrDocument; import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrDocumentList; import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.params.CommonParams; import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.util.NamedList; import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.XML; 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) { public XMLWriter(Writer writer, SolrQueryRequest req, SolrQueryResponse rsp) {
super(writer, req, 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); float ver = version==null? CURRENT_VERSION : Float.parseFloat(version);
this.version = (int)(ver*1000); 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 sz = lst.size();
int start=0; 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++) { for (int i=start; i<sz; i++) {
writeVal(lst.getName(i),lst.getVal(i)); writeVal(lst.getName(i),lst.getVal(i));
} }
@ -248,7 +231,7 @@ public final class XMLWriter extends TextResponseWriter {
} }
if (fidx1+1 == fidx2) { if (fidx1+1 == fidx2) {
// single field value // single field value
if (version>=2100 && sf.multiValued()) { if (sf.multiValued()) {
startTag("arr",fname,false); startTag("arr",fname,false);
doIndent=false; doIndent=false;
sf.write(this, null, f1); sf.write(this, null, f1);
@ -301,7 +284,7 @@ public final class XMLWriter extends TextResponseWriter {
} else { } else {
// single valued... figure out if we should put <arr> tags around it anyway // single valued... figure out if we should put <arr> tags around it anyway
SchemaField sf = schema.getFieldOrNull(fname); SchemaField sf = schema.getFieldOrNull(fname);
if (version>=2100 && sf!=null && sf.multiValued()) { if (sf!=null && sf.multiValued()) {
startTag("arr",fname,false); startTag("arr",fname,false);
doIndent=false; doIndent=false;
writeVal(fname, val); writeVal(fname, val);

View File

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

View File

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

View File

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

View File

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

View File

@ -20,6 +20,7 @@ package org.apache.solr;
import java.io.IOException; import java.io.IOException;
import java.io.Writer; import java.io.Writer;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.util.NamedList; import org.apache.solr.common.util.NamedList;
import org.apache.solr.request.SolrQueryRequest; import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.response.QueryResponseWriter; 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 @Test
public void testSOLR59responseHeaderVersions() { public void testSOLR59responseHeaderVersions() {
// default version is 2.2, with "new" responseHeader // default version is 2.2, with "new" responseHeader
lrf.args.remove("version"); lrf.args.remove(CommonParams.VERSION);
lrf.args.put("wt", "standard"); lrf.args.put("wt", "standard");
assertQ(req("foo"), "/response/lst[@name='responseHeader']/int[@name='status'][.='0']"); assertQ(req("foo"), "/response/lst[@name='responseHeader']/int[@name='status'][.='0']");
lrf.args.remove("wt"); lrf.args.remove("wt");
assertQ(req("foo"), "/response/lst[@name='responseHeader']/int[@name='QTime']"); 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 // and explicit 2.2 works as default
lrf.args.put("version", "2.2"); //lrf.args.put("version", "2.2");
lrf.args.put("wt", "standard"); lrf.args.put("wt", "standard");
assertQ(req("foo"), "/response/lst[@name='responseHeader']/int[@name='status'][.='0']"); assertQ(req("foo"), "/response/lst[@name='responseHeader']/int[@name='status'][.='0']");
lrf.args.remove("wt"); lrf.args.remove("wt");

View File

@ -17,6 +17,7 @@
package org.apache.solr; package org.apache.solr;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.request.*; import org.apache.solr.request.*;
import org.apache.solr.util.*; import org.apache.solr.util.*;
import org.junit.BeforeClass; import org.junit.BeforeClass;
@ -46,7 +47,7 @@ public class SampleTest extends SolrTestCaseJ4 {
*/ */
@Test @Test
public void testSimple() { public void testSimple() {
lrf.args.put("version","2.0"); lrf.args.put(CommonParams.VERSION,"2.2");
assertU("Simple assertion that adding a document works", assertU("Simple assertion that adding a document works",
adoc("id", "4055", adoc("id", "4055",
"subject", "Hoss the Hoss man Hostetter")); "subject", "Hoss the Hoss man Hostetter"));
@ -70,7 +71,7 @@ public class SampleTest extends SolrTestCaseJ4 {
*/ */
@Test @Test
public void testAdvanced() throws Exception { 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", assertU("less common case, a complex addition with options",
add(doc("id", "4059", add(doc("id", "4059",
"subject", "Who Me?"), "subject", "Who Me?"),
@ -102,7 +103,7 @@ public class SampleTest extends SolrTestCaseJ4 {
* Note: the qt proves we are using our custom config... * Note: the qt proves we are using our custom config...
*/ */
TestHarness.LocalRequestFactory l = h.getRequestFactory 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? ", assertQ("how did i find Mack Daddy? ",
l.makeRequest( "Mack Daddy" ) l.makeRequest( "Mack Daddy" )
,"//result[@numFound=0]" ,"//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.SolrException;
import org.apache.solr.common.SolrInputDocument; import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.SolrInputField; 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.ModifiableSolrParams;
import org.apache.solr.common.params.SolrParams; import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.XML; import org.apache.solr.common.util.XML;
@ -238,7 +239,7 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {
solrConfig, solrConfig,
getSchemaFile()); getSchemaFile());
lrf = h.getRequestFactory lrf = h.getRequestFactory
("standard",0,20,"version","2.2"); ("standard",0,20,CommonParams.VERSION,"2.2");
} }
log.info("####initCore end"); log.info("####initCore end");
} }

View File

@ -18,6 +18,7 @@ package org.apache.solr.cloud;
*/ */
import org.apache.lucene.index.LogMergePolicy; import org.apache.lucene.index.LogMergePolicy;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.core.SolrCore; import org.apache.solr.core.SolrCore;
import org.apache.solr.update.SolrIndexWriter; 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); assertEquals("Mergefactor was not picked up", ((LogMergePolicy)writer.getConfig().getMergePolicy()).getMergeFactor(), 8);
writer.close(); writer.close();
lrf.args.put("version", "2.0"); lrf.args.put(CommonParams.VERSION, "2.2");
assertQ("test query on empty index", req("qlkciyopsbgzyvkylsjhchghjrdf"), assertQ("test query on empty index", req("qlkciyopsbgzyvkylsjhchghjrdf"),
"//result[@numFound='0']"); "//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.store.Directory;
import org.apache.lucene.util.Version; import org.apache.lucene.util.Version;
import org.apache.solr.common.SolrException; import org.apache.solr.common.SolrException;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.util.AbstractSolrTestCase; import org.apache.solr.util.AbstractSolrTestCase;
import org.apache.solr.util.TestHarness; import org.apache.solr.util.TestHarness;
import org.junit.Test; import org.junit.Test;
@ -56,7 +57,7 @@ public class TestArbitraryIndexDir extends AbstractSolrTestCase{
solrConfig, solrConfig,
"schema12.xml"); "schema12.xml");
lrf = h.getRequestFactory lrf = h.getRequestFactory
("standard",0,20,"version","2.2"); ("standard",0,20,CommonParams.VERSION,"2.2");
} }
@Override @Override

View File

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