You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by yo...@apache.org on 2011/03/15 22:35:35 UTC
svn commit: r1081952 [17/17] - in /lucene/dev/branches/bulkpostings: ./
dev-tools/ dev-tools/eclipse/ dev-tools/idea/ dev-tools/idea/.idea/
dev-tools/idea/lucene/ dev-tools/idea/lucene/contrib/ant/
dev-tools/idea/lucene/contrib/demo/ dev-tools/idea/luc...
Modified: lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/ConvertedLegacyTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/ConvertedLegacyTest.java?rev=1081952&r1=1081951&r2=1081952&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/ConvertedLegacyTest.java (original)
+++ lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/ConvertedLegacyTest.java Tue Mar 15 21:35:17 2011
@@ -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
// 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
,"//*[@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
,"//*[@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
,"*[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
,"*[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
,"*[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
,"*//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
,"*//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
,"*//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
,"*[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
,"*[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
,"*[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
,"*[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
,"*[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
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
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
);
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
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
,"//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
// 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
,"*[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
,"*[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
// 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
,"//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
,"//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
,"//@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
,"//@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;",
Modified: lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/DisMaxRequestHandlerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/DisMaxRequestHandlerTest.java?rev=1081952&r1=1081951&r2=1081952&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/DisMaxRequestHandlerTest.java (original)
+++ lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/DisMaxRequestHandlerTest.java Tue Mar 15 21:35:17 2011
@@ -32,7 +32,7 @@ public class DisMaxRequestHandlerTest ex
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 ex
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 ex
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 ex
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 ex
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 ex
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"
Modified: lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/EchoParamsTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/EchoParamsTest.java?rev=1081952&r1=1081951&r2=1081952&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/EchoParamsTest.java (original)
+++ lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/EchoParamsTest.java Tue Mar 15 21:35:17 2011
@@ -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 Solr
@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 Solr
@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 Solr
@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 Solr
public void testAllEchoParams() {
lrf = h.getRequestFactory
("crazy_custom_qt", 0, 20,
- "version","2.2",
+ CommonParams.VERSION,"2.2",
"wt","xml",
"echoParams", "all",
"echoHandler","true"
Modified: lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/MinimalSchemaTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/MinimalSchemaTest.java?rev=1081952&r1=1081951&r2=1081952&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/MinimalSchemaTest.java (original)
+++ lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/MinimalSchemaTest.java Tue Mar 15 21:35:17 2011
@@ -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 S
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",
Modified: lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/OutputWriterTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/OutputWriterTest.java?rev=1081952&r1=1081951&r2=1081952&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/OutputWriterTest.java (original)
+++ lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/OutputWriterTest.java Tue Mar 15 21:35:17 2011
@@ -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 So
}
- /** 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");
@@ -83,6 +80,15 @@ public class OutputWriterTest extends So
assertTrue(out.contains("DUMMY"));
}
+ @Test
+ public void testTrivialXsltWriterInclude() throws Exception {
+ lrf.args.put("wt", "xslt");
+ lrf.args.put("tr", "dummy-using-include.xsl");
+ String out = h.query(req("foo"));
+ // System.out.println(out);
+ assertTrue(out.contains("DUMMY"));
+ }
+
////////////////////////////////////////////////////////////////////////////
/** An output writer that doesn't do anything useful. */
Modified: lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/SampleTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/SampleTest.java?rev=1081952&r1=1081951&r2=1081952&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/SampleTest.java (original)
+++ lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/SampleTest.java Tue Mar 15 21:35:17 2011
@@ -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 SolrTest
*/
@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 SolrTest
*/
@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 SolrTest
* 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]"
Modified: lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/SolrTestCaseJ4.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/SolrTestCaseJ4.java?rev=1081952&r1=1081951&r2=1081952&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/SolrTestCaseJ4.java (original)
+++ lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/SolrTestCaseJ4.java Tue Mar 15 21:35:17 2011
@@ -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 ext
solrConfig,
getSchemaFile());
lrf = h.getRequestFactory
- ("standard",0,20,"version","2.2");
+ ("standard",0,20,CommonParams.VERSION,"2.2");
}
log.info("####initCore end");
}
Modified: lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/TestDistributedSearch.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/TestDistributedSearch.java?rev=1081952&r1=1081951&r2=1081952&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/TestDistributedSearch.java (original)
+++ lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/TestDistributedSearch.java Tue Mar 15 21:35:17 2011
@@ -137,6 +137,7 @@ public class TestDistributedSearch exten
query("q","*:*", "rows",100, "facet","true", "facet.field",t1, "facet.limit",-1, "facet.sort","count", "facet.mincount",2);
query("q","*:*", "rows",100, "facet","true", "facet.field",t1, "facet.limit",-1, "facet.sort","index");
query("q","*:*", "rows",100, "facet","true", "facet.field",t1, "facet.limit",-1, "facet.sort","index", "facet.mincount",2);
+ query("q","*:*", "rows",100, "facet","true", "facet.field",t1, "facet.offset",10, "facet.limit",1, "facet.sort","index");
query("q","*:*", "rows",100, "facet","true", "facet.field",t1,"facet.limit",1);
query("q","*:*", "rows",100, "facet","true", "facet.query","quick", "facet.query","all", "facet.query","*:*");
query("q","*:*", "rows",100, "facet","true", "facet.field",t1, "facet.offset",1);
Modified: lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/client/solrj/SolrExampleTests.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/client/solrj/SolrExampleTests.java?rev=1081952&r1=1081951&r2=1081952&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/client/solrj/SolrExampleTests.java (original)
+++ lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/client/solrj/SolrExampleTests.java Tue Mar 15 21:35:17 2011
@@ -27,6 +27,10 @@ import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import junit.framework.Assert;
+import org.apache.lucene.util._TestUtil;
+import org.apache.solr.client.solrj.impl.BinaryResponseParser;
+import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
+import org.apache.solr.client.solrj.impl.XMLResponseParser;
import org.apache.solr.client.solrj.request.DirectXmlRequest;
import org.apache.solr.client.solrj.request.LukeRequest;
import org.apache.solr.client.solrj.request.SolrPing;
@@ -181,7 +185,7 @@ abstract public class SolrExampleTests e
SolrInputDocument doc2 = new SolrInputDocument();
doc2.addField( "id", "id2", 1.0f );
- doc2.addField( "name", "h\u1234llo", 1.0f );
+ doc2.addField( "name", "h\uD866\uDF05llo", 1.0f );
doc2.addField( "price", 20 );
Collection<SolrInputDocument> docs = new ArrayList<SolrInputDocument>();
@@ -209,12 +213,96 @@ abstract public class SolrExampleTests e
// System.out.println( rsp.getResults() );
// query outside ascii range
- query.setQuery("name:h\u1234llo");
+ query.setQuery("name:h\uD866\uDF05llo");
rsp = server.query( query );
assertEquals( 1, rsp.getResults().getNumFound() );
}
+ private String randomTestString(int maxLength) {
+ // we can't just use _TestUtil.randomUnicodeString() or we might get 0xfffe etc
+ // (considered invalid by XML)
+
+ int size = random.nextInt(maxLength);
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < size; i++) {
+ switch(random.nextInt(4)) {
+ case 0: /* single byte */
+ sb.append('a');
+ break;
+ case 1: /* two bytes */
+ sb.append('\u0645');
+ break;
+ case 2: /* three bytes */
+ sb.append('\u092a');
+ break;
+ case 3: /* four bytes */
+ sb.appendCodePoint(0x29B05);
+ }
+ }
+ return sb.toString();
+ }
+
+ public void testUnicode() throws Exception {
+ int numIterations = 100 * RANDOM_MULTIPLIER;
+
+ SolrServer server = getSolrServer();
+
+ // save the old parser, so we can set it back.
+ ResponseParser oldParser = null;
+ if (server instanceof CommonsHttpSolrServer) {
+ CommonsHttpSolrServer cserver = (CommonsHttpSolrServer) server;
+ oldParser = cserver.getParser();
+ }
+
+ try {
+ for (int iteration = 0; iteration < numIterations; iteration++) {
+ // choose format
+ if (server instanceof CommonsHttpSolrServer) {
+ if (random.nextBoolean()) {
+ ((CommonsHttpSolrServer) server).setParser(new BinaryResponseParser());
+ } else {
+ ((CommonsHttpSolrServer) server).setParser(new XMLResponseParser());
+ }
+ }
+
+ int numDocs = _TestUtil.nextInt(random, 1, 100);
+
+ // Empty the database...
+ server.deleteByQuery("*:*");// delete everything!
+
+ List<SolrInputDocument> docs = new ArrayList<SolrInputDocument>();
+ for (int i = 0; i < numDocs; i++) {
+ // Now add something...
+ SolrInputDocument doc = new SolrInputDocument();
+ doc.addField("id", "" + i);
+ doc.addField("unicode_s", randomTestString(30));
+ docs.add(doc);
+ }
+
+ server.add(docs);
+ server.commit();
+
+ SolrQuery query = new SolrQuery();
+ query.setQuery("*:*");
+ query.setRows(numDocs);
+
+ QueryResponse rsp = server.query( query );
+
+ for (int i = 0; i < numDocs; i++) {
+ String expected = (String) docs.get(i).getFieldValue("unicode_s");
+ String actual = (String) rsp.getResults().get(i).getFieldValue("unicode_s");
+ assertEquals(expected, actual);
+ }
+ }
+ } finally {
+ if (oldParser != null) {
+ // set the old parser back
+ ((CommonsHttpSolrServer)server).setParser(oldParser);
+ }
+ }
+ }
+
/**
* query the example
*/
@@ -471,8 +559,8 @@ abstract public class SolrExampleTests e
assertEquals( "they have the same distribution", inStockF.getStddev(), inStockT.getStddev() );
}
- @Test
- public void testPingHandler() throws Exception
+ @Test
+ public void testPingHandler() throws Exception
{
SolrServer server = getSolrServer();
@@ -495,8 +583,8 @@ abstract public class SolrExampleTests e
}
}
- @Test
- public void testFaceting() throws Exception
+ @Test
+ public void testFaceting() throws Exception
{
SolrServer server = getSolrServer();
Modified: lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/cloud/BasicZkTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/cloud/BasicZkTest.java?rev=1081952&r1=1081951&r2=1081952&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/cloud/BasicZkTest.java (original)
+++ lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/cloud/BasicZkTest.java Tue Mar 15 21:35:17 2011
@@ -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 Abstrac
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']");
Modified: lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/cloud/ZkSolrClientTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/cloud/ZkSolrClientTest.java?rev=1081952&r1=1081951&r2=1081952&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/cloud/ZkSolrClientTest.java (original)
+++ lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/cloud/ZkSolrClientTest.java Tue Mar 15 21:35:17 2011
@@ -40,7 +40,7 @@ public class ZkSolrClientTest extends Ab
server = new ZkTestServer(zkDir);
server.run();
- SolrZkClient zkClient = new SolrZkClient(server.getZkAddress(), 100);
+ SolrZkClient zkClient = new SolrZkClient(server.getZkAddress(), AbstractZkTestCase.TIMEOUT);
zkClient.close();
server.shutdown();
Modified: lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/core/TestArbitraryIndexDir.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/core/TestArbitraryIndexDir.java?rev=1081952&r1=1081951&r2=1081952&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/core/TestArbitraryIndexDir.java (original)
+++ lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/core/TestArbitraryIndexDir.java Tue Mar 15 21:35:17 2011
@@ -32,6 +32,7 @@ import org.apache.lucene.queryParser.Par
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 exten
solrConfig,
"schema12.xml");
lrf = h.getRequestFactory
- ("standard",0,20,"version","2.2");
+ ("standard",0,20,CommonParams.VERSION,"2.2");
}
@Override
Modified: lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/core/TestXIncludeConfig.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/core/TestXIncludeConfig.java?rev=1081952&r1=1081951&r2=1081952&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/core/TestXIncludeConfig.java (original)
+++ lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/core/TestXIncludeConfig.java Tue Mar 15 21:35:17 2011
@@ -17,11 +17,8 @@ package org.apache.solr.core;
* limitations under the License.
*/
-import java.io.File;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.solr.util.AbstractSolrTestCase;
import org.apache.solr.request.SolrRequestHandler;
+import org.apache.solr.util.AbstractSolrTestCase;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -46,19 +43,16 @@ public class TestXIncludeConfig extends
@Override
public void setUp() throws Exception {
- File dest = new File("solrconfig-reqHandler.incl");
- dest.deleteOnExit();
- FileUtils.copyFile(getFile("solr/conf/solrconfig-reqHandler.incl"), dest);
supports = true;
javax.xml.parsers.DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
try {
//see whether it even makes sense to run this test
dbf.setXIncludeAware(true);
dbf.setNamespaceAware(true);
- super.setUp();
} catch (UnsupportedOperationException e) {
supports = false;
}
+ super.setUp();
}
public void testXInclude() throws Exception {
Modified: lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/handler/TestCSVLoader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/handler/TestCSVLoader.java?rev=1081952&r1=1081951&r2=1081952&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/handler/TestCSVLoader.java (original)
+++ lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/handler/TestCSVLoader.java Tue Mar 15 21:35:17 2011
@@ -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 SolrT
@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 SolrT
// 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 SolrT
// 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 SolrT
// 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 SolrT
"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 SolrT
"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 SolrT
);
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 SolrT
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']");
}
Modified: lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/request/SimpleFacetsTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/request/SimpleFacetsTest.java?rev=1081952&r1=1081951&r2=1081952&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/request/SimpleFacetsTest.java (original)
+++ lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/request/SimpleFacetsTest.java Tue Mar 15 21:35:17 2011
@@ -370,6 +370,12 @@ public class SimpleFacetsTest extends So
final String pre = "//lst[@name='"+b+"']/lst[@name='"+f+"']" + c;
final String meta = pre + (rangeMode ? "/../" : "");
+
+ // date faceting defaults to include both endpoints,
+ // range faceting defaults to including only lower
+ // doc exists with value @ 00:00:00.000 on July5
+ final String jul4 = rangeMode ? "[.='1' ]" : "[.='2' ]";
+
assertQ("check counts for month of facet by day",
req( "q", "*:*"
,"rows", "0"
@@ -381,12 +387,10 @@ public class SimpleFacetsTest extends So
,p+".other", "all"
)
,"*[count("+pre+"/int)="+(rangeMode ? 31 : 34)+"]"
- ,pre+"/int[@name='1976-07-01T00:00:00Z'][.='0' ]"
- ,pre+"/int[@name='1976-07-02T00:00:00Z'][.='0' ]"
+ ,pre+"/int[@name='1976-07-01T00:00:00Z'][.='0']"
+ ,pre+"/int[@name='1976-07-02T00:00:00Z'][.='0']"
,pre+"/int[@name='1976-07-03T00:00:00Z'][.='2' ]"
- // july4th = 2 because exists doc @ 00:00:00.000 on July5
- // (date faceting is inclusive)
- ,pre+"/int[@name='1976-07-04T00:00:00Z'][.='2' ]"
+ ,pre+"/int[@name='1976-07-04T00:00:00Z']" + jul4
,pre+"/int[@name='1976-07-05T00:00:00Z'][.='2' ]"
,pre+"/int[@name='1976-07-06T00:00:00Z'][.='0']"
,pre+"/int[@name='1976-07-07T00:00:00Z'][.='0']"
@@ -433,9 +437,7 @@ public class SimpleFacetsTest extends So
)
,"*[count("+pre+"/int)="+(rangeMode ? 8 : 11)+"]"
,pre+"/int[@name='1976-07-03T00:00:00Z'][.='2' ]"
- // july4th = 2 because exists doc @ 00:00:00.000 on July5
- // (date faceting is inclusive)
- ,pre+"/int[@name='1976-07-04T00:00:00Z'][.='2' ]"
+ ,pre+"/int[@name='1976-07-04T00:00:00Z']" + jul4
,pre+"/int[@name='1976-07-05T00:00:00Z'][.='2' ]"
,pre+"/int[@name='1976-07-12T00:00:00Z'][.='1' ]"
,pre+"/int[@name='1976-07-13T00:00:00Z'][.='1' ]"
@@ -458,11 +460,9 @@ public class SimpleFacetsTest extends So
,p+".other", "all"
,"f." + f + ".facet.mincount", "2"
)
- ,"*[count("+pre+"/int)="+(rangeMode ? 4 : 7)+"]"
+ ,"*[count("+pre+"/int)="+(rangeMode ? 3 : 7)+"]"
,pre+"/int[@name='1976-07-03T00:00:00Z'][.='2' ]"
- // july4th = 2 because exists doc @ 00:00:00.000 on July5
- // (date faceting is inclusive)
- ,pre+"/int[@name='1976-07-04T00:00:00Z'][.='2' ]"
+ ,pre+(rangeMode ? "" : "/int[@name='1976-07-04T00:00:00Z']" +jul4)
,pre+"/int[@name='1976-07-05T00:00:00Z'][.='2' ]"
,pre+"/int[@name='1976-07-15T00:00:00Z'][.='2' ]"
,meta+"/int[@name='before' ][.='2']"
@@ -482,11 +482,11 @@ public class SimpleFacetsTest extends So
)
,"*[count("+pre+"/int)="+(rangeMode ? 2 : 5)+"]"
,pre+"/int[@name='1976-07-05T00:00:00Z'][.='2' ]"
- ,pre+"/int[@name='1976-07-06T00:00:00Z'][.='0' ]"
+ ,pre+"/int[@name='1976-07-06T00:00:00Z'][.='0']"
,meta+"/int[@name='before' ][.='5']"
);
- assertQ("check after is not inclusive of lower bound by default",
+ assertQ("check after is not inclusive of lower bound by default (for dates)",
req("q", "*:*"
,"rows", "0"
,"facet", "true"
@@ -498,9 +498,9 @@ public class SimpleFacetsTest extends So
)
,"*[count("+pre+"/int)="+(rangeMode ? 2 : 5)+"]"
,pre+"/int[@name='1976-07-03T00:00:00Z'][.='2' ]"
- ,pre+"/int[@name='1976-07-04T00:00:00Z'][.='2' ]"
+ ,pre+"/int[@name='1976-07-04T00:00:00Z']" + jul4
- ,meta+"/int[@name='after' ][.='8']"
+ ,meta+"/int[@name='after' ][.='"+(rangeMode ? 9 : 8)+"']"
);
Modified: lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/schema/BadIndexSchemaTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/schema/BadIndexSchemaTest.java?rev=1081952&r1=1081951&r2=1081952&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/schema/BadIndexSchemaTest.java (original)
+++ lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/schema/BadIndexSchemaTest.java Tue Mar 15 21:35:17 2011
@@ -22,6 +22,8 @@ import org.apache.solr.common.SolrExcept
import org.apache.solr.common.SolrException.ErrorCode;
import org.apache.solr.core.SolrConfig;
+import java.util.regex.Pattern;
+
import org.junit.Test;
public class BadIndexSchemaTest extends SolrTestCaseJ4 {
@@ -29,7 +31,7 @@ public class BadIndexSchemaTest extends
private void doTest(final String schema, final String errString)
throws Exception {
- ignoreException(errString);
+ ignoreException(Pattern.quote(errString));
try {
initCore( "solrconfig.xml", schema );
} catch (SolrException e) {
@@ -60,4 +62,9 @@ public class BadIndexSchemaTest extends
public void testSevereErrorsForDuplicateFieldType() throws Exception {
doTest("bad-schema-dup-fieldType.xml", "ftAgain");
}
+
+ @Test
+ public void testSevereErrorsForUnexpectedAnalyzer() throws Exception {
+ doTest("bad-schema-nontext-analyzer.xml", "StrField (bad_type)");
+ }
}
Modified: lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/search/QueryParsingTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/search/QueryParsingTest.java?rev=1081952&r1=1081951&r2=1081952&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/search/QueryParsingTest.java (original)
+++ lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/search/QueryParsingTest.java Tue Mar 15 21:35:17 2011
@@ -102,10 +102,10 @@ public class QueryParsingTest extends So
assertEquals(flds[0].getField(), "pow(float(weight),const(2.0))");
//test functions (more deep)
- sort = QueryParsing.parseSort("sum(product(r_f,sum(d_f,t_f,1)),a_f) asc", req);
+ sort = QueryParsing.parseSort("sum(product(r_f1,sum(d_f1,t_f1,1)),a_f1) asc", req);
flds = sort.getSort();
assertEquals(flds[0].getType(), SortField.CUSTOM);
- assertEquals(flds[0].getField(), "sum(product(float(r_f),sum(float(d_f),float(t_f),const(1.0))),float(a_f))");
+ assertEquals(flds[0].getField(), "sum(product(float(r_f1),sum(float(d_f1),float(t_f1),const(1.0))),float(a_f1))");
sort = QueryParsing.parseSort("pow(weight, 2) desc", req);
flds = sort.getSort();
@@ -135,11 +135,11 @@ public class QueryParsingTest extends So
assertEquals(flds[0].getField(), "weight");
//Test literals in functions
- sort = QueryParsing.parseSort("strdist(foo_s, \"junk\", jw) desc", req);
+ sort = QueryParsing.parseSort("strdist(foo_s1, \"junk\", jw) desc", req);
flds = sort.getSort();
assertEquals(flds[0].getType(), SortField.CUSTOM);
//the value sources get wrapped, so the out field is different than the input
- assertEquals(flds[0].getField(), "strdist(str(foo_s),literal(junk), dist=org.apache.lucene.search.spell.JaroWinklerDistance)");
+ assertEquals(flds[0].getField(), "strdist(str(foo_s1),literal(junk), dist=org.apache.lucene.search.spell.JaroWinklerDistance)");
sort = QueryParsing.parseSort("", req);
assertNull(sort);
Modified: lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/search/TestFastLRUCache.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/search/TestFastLRUCache.java?rev=1081952&r1=1081951&r2=1081952&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/search/TestFastLRUCache.java (original)
+++ lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/search/TestFastLRUCache.java Tue Mar 15 21:35:17 2011
@@ -254,6 +254,18 @@ public class TestFastLRUCache extends Lu
cache.destroy();
}
+ // enough randomness to exercise all of the different cache purging phases
+ public void testRandom() {
+ int sz = random.nextInt(100)+5;
+ int lowWaterMark = random.nextInt(sz-3)+1;
+ int keyrange = random.nextInt(sz*3)+1;
+ ConcurrentLRUCache<Integer, String> cache = new ConcurrentLRUCache<Integer, String>(sz, lowWaterMark);
+ for (int i=0; i<10000; i++) {
+ cache.put(random.nextInt(keyrange), "");
+ cache.get(random.nextInt(keyrange));
+ }
+ }
+
void doPerfTest(int iter, int cacheSize, int maxKey) {
long start = System.currentTimeMillis();
Modified: lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/search/TestIndexSearcher.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/search/TestIndexSearcher.java?rev=1081952&r1=1081951&r2=1081952&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/search/TestIndexSearcher.java (original)
+++ lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/search/TestIndexSearcher.java Tue Mar 15 21:35:17 2011
@@ -59,18 +59,18 @@ public class TestIndexSearcher extends S
public void testReopen() throws Exception {
- assertU(adoc("id","1", "v_t","Hello Dude", "v_s","string1"));
- assertU(adoc("id","2", "v_t","Hello Yonik", "v_s","string2"));
+ assertU(adoc("id","1", "v_t","Hello Dude", "v_s1","string1"));
+ assertU(adoc("id","2", "v_t","Hello Yonik", "v_s1","string2"));
assertU(commit());
SolrQueryRequest sr1 = req("q","foo");
ReaderContext rCtx1 = sr1.getSearcher().getTopReaderContext();
- String sval1 = getStringVal(sr1, "v_s",0);
+ String sval1 = getStringVal(sr1, "v_s1",0);
assertEquals("string1", sval1);
- assertU(adoc("id","3", "v_s","{!literal}"));
- assertU(adoc("id","4", "v_s","other stuff"));
+ assertU(adoc("id","3", "v_s1","{!literal}"));
+ assertU(adoc("id","4", "v_s1","other stuff"));
assertU(commit());
SolrQueryRequest sr2 = req("q","foo");
@@ -81,7 +81,7 @@ public class TestIndexSearcher extends S
assertEquals(ReaderUtil.leaves(rCtx1)[0].reader, ReaderUtil.leaves(rCtx2)[0].reader);
assertU(adoc("id","5", "v_f","3.14159"));
- assertU(adoc("id","6", "v_f","8983", "v_s","string6"));
+ assertU(adoc("id","6", "v_f","8983", "v_s1","string6"));
assertU(commit());
SolrQueryRequest sr3 = req("q","foo");
@@ -129,4 +129,4 @@ public class TestIndexSearcher extends S
sr5.close();
sr6.close();
}
-}
\ No newline at end of file
+}
Modified: lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/search/TestQueryTypes.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/search/TestQueryTypes.java?rev=1081952&r1=1081951&r2=1081952&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/search/TestQueryTypes.java (original)
+++ lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/search/TestQueryTypes.java Tue Mar 15 21:35:17 2011
@@ -87,7 +87,6 @@ public class TestQueryTypes extends Abst
,"//*[@name='id'][.='999.0']"
,"//*[@name='" + f + "'][.='" + v + "']"
);
- // System.out.println("#########################################" + f + "=" + v);
// field qparser
assertQ(req( "q", "{!field f="+f+"}"+v)
@@ -98,20 +97,34 @@ public class TestQueryTypes extends Abst
assertQ(req( "q", f + ":[\"" + v + "\" TO \"" + v + "\"]" )
,"//result[@numFound='1']"
);
+ }
+ // frange and function query only work on single valued field types
+ Object[] fc_vals = new Object[] {
+ "id",999.0
+ ,"v_s","wow dude"
+ ,"v_ti",-1
+ ,"v_tl",-1234567891234567890L
+ ,"v_tf",-2.0f
+ ,"v_td",-2.0
+ ,"v_tdt","2000-05-10T01:01:01Z"
+ };
+
+ for (int i=0; i<fc_vals.length; i+=2) {
+ String f = fc_vals[i].toString();
+ String v = fc_vals[i+1].toString();
+
// frange qparser
assertQ(req( "q", "{!frange v="+f+" l='"+v+"' u='"+v+"'}" )
,"//result[@numFound='1']"
);
-
+
// function query... just make sure it doesn't throw an exception
- assertQ(req( "q", "+id:999 _val_:\"" + f + "\"")
- ,"//result[@numFound='1']"
- );
-
+ assertQ(req( "q", "+id:999 _val_:\"" + f + "\"")
+ ,"//result[@numFound='1']"
+ );
}
-
// Some basic tests to ensure that parsing local params is working
assertQ("test prefix query",
req("q","{!prefix f=v_t}hel")
@@ -318,4 +331,4 @@ public class TestQueryTypes extends Abst
);
}
-}
\ No newline at end of file
+}
Modified: lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/search/function/SortByFunctionTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/search/function/SortByFunctionTest.java?rev=1081952&r1=1081951&r2=1081952&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/search/function/SortByFunctionTest.java (original)
+++ lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/search/function/SortByFunctionTest.java Tue Mar 15 21:35:17 2011
@@ -35,10 +35,10 @@ public class SortByFunctionTest extends
}
public void test() throws Exception {
- assertU(adoc("id", "1", "x_td", "0", "y_td", "2", "w_td1", "25", "z_td", "5", "f_t", "ipod"));
- assertU(adoc("id", "2", "x_td", "2", "y_td", "2", "w_td1", "15", "z_td", "5", "f_t", "ipod ipod ipod ipod ipod"));
- assertU(adoc("id", "3", "x_td", "3", "y_td", "2", "w_td1", "55", "z_td", "5", "f_t", "ipod ipod ipod ipod ipod ipod ipod ipod ipod"));
- assertU(adoc("id", "4", "x_td", "4", "y_td", "2", "w_td1", "45", "z_td", "5", "f_t", "ipod ipod ipod ipod ipod ipod ipod"));
+ assertU(adoc("id", "1", "x_td1", "0", "y_td1", "2", "w_td1", "25", "z_td1", "5", "f_t", "ipod"));
+ assertU(adoc("id", "2", "x_td1", "2", "y_td1", "2", "w_td1", "15", "z_td1", "5", "f_t", "ipod ipod ipod ipod ipod"));
+ assertU(adoc("id", "3", "x_td1", "3", "y_td1", "2", "w_td1", "55", "z_td1", "5", "f_t", "ipod ipod ipod ipod ipod ipod ipod ipod ipod"));
+ assertU(adoc("id", "4", "x_td1", "4", "y_td1", "2", "w_td1", "45", "z_td1", "5", "f_t", "ipod ipod ipod ipod ipod ipod ipod"));
assertU(commit());
assertQ(req("fl", "*,score", "q", "*:*"),
@@ -66,7 +66,7 @@ public class SortByFunctionTest extends
);
- assertQ(req("fl", "*,score", "q", "*:*", "sort", "sum(x_td, y_td) desc"),
+ assertQ(req("fl", "*,score", "q", "*:*", "sort", "sum(x_td1, y_td1) desc"),
"//*[@numFound='4']",
"//float[@name='score']='1.0'",
"//result/doc[1]/int[@name='id'][.='4']",
@@ -74,7 +74,7 @@ public class SortByFunctionTest extends
"//result/doc[3]/int[@name='id'][.='2']",
"//result/doc[4]/int[@name='id'][.='1']"
);
- assertQ(req("fl", "*,score", "q", "*:*", "sort", "sum(x_td, y_td) asc"),
+ assertQ(req("fl", "*,score", "q", "*:*", "sort", "sum(x_td1, y_td1) asc"),
"//*[@numFound='4']",
"//float[@name='score']='1.0'",
"//result/doc[1]/int[@name='id'][.='1']",
@@ -83,7 +83,7 @@ public class SortByFunctionTest extends
"//result/doc[4]/int[@name='id'][.='4']"
);
//the function is equal, w_td1 separates
- assertQ(req("q", "*:*", "fl", "id", "sort", "sum(z_td, y_td) asc, w_td1 asc"),
+ assertQ(req("q", "*:*", "fl", "id", "sort", "sum(z_td1, y_td1) asc, w_td1 asc"),
"//*[@numFound='4']",
"//result/doc[1]/int[@name='id'][.='2']",
"//result/doc[2]/int[@name='id'][.='1']",
@@ -124,7 +124,3 @@ public class SortByFunctionTest extends
);
}
}
-
-/*
-<lst name="responseHeader"><int name="status">0</int><int name="QTime">93</int></lst><result name="response" numFound="4" start="0" maxScore="1.0"><doc><float name="score">1.0</float><int name="id">4</int><int name="intDefault">42</int><arr name="multiDefault"><str>muLti-Default</str></arr><date name="timestamp">2009-12-12T12:59:46.412Z</date><arr name="x_td"><double>4.0</double></arr><arr name="y_td"><double>2.0</double></arr></doc><doc><float name="score">1.0</float><int name="id">3</int><int name="intDefault">42</int><arr name="multiDefault"><str>muLti-Default</str></arr><date name="timestamp">2009-12-12T12:59:46.409Z</date><arr name="x_td"><double>3.0</double></arr><arr name="y_td"><double>2.0</double></arr></doc><doc><float name="score">1.0</float><int name="id">2</int><int name="intDefault">42</int><arr name="multiDefault"><str>muLti-Default</str></arr><date name="timestamp">2009-12-12T12:59:46.406Z</date><arr name="x_td"><double>2.0</double></arr><arr name="y_td"><dou
ble>2.0</double></arr></doc><doc><float name="score">1.0</float><int name="id">1</int><int name="intDefault">42</int><arr name="multiDefault"><str>muLti-Default</str></arr><date name="timestamp">2009-12-12T12:59:46.361Z</date><arr name="x_td"><double>0.0</double></arr><arr name="y_td"><double>2.0</double></arr></doc></result>
-*/
Modified: lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/search/function/TestFunctionQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/search/function/TestFunctionQuery.java?rev=1081952&r1=1081951&r2=1081952&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/search/function/TestFunctionQuery.java (original)
+++ lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/search/function/TestFunctionQuery.java Tue Mar 15 21:35:17 2011
@@ -498,6 +498,8 @@ public class TestFunctionQuery extends S
dofunc("deg(.5)", Math.toDegrees(.5));
dofunc("sqrt(9)", Math.sqrt(9));
dofunc("cbrt(8)", Math.cbrt(8));
+ dofunc("max(0,1)", Math.max(0,1));
+ dofunc("min(0,1)", Math.min(0,1));
dofunc("log(100)", Math.log10(100));
dofunc("ln(3)", Math.log(3));
dofunc("exp(1)", Math.exp(1));
Modified: lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/search/function/distance/DistanceFunctionTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/search/function/distance/DistanceFunctionTest.java?rev=1081952&r1=1081951&r2=1081952&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/search/function/distance/DistanceFunctionTest.java (original)
+++ lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/search/function/distance/DistanceFunctionTest.java Tue Mar 15 21:35:17 2011
@@ -36,12 +36,12 @@ public class DistanceFunctionTest extend
@Test
public void testHaversine() throws Exception {
clearIndex();
- assertU(adoc("id", "1", "x_td", "0", "y_td", "0", "gh_s", GeoHashUtils.encode(32.7693246, -79.9289094)));
- assertU(adoc("id", "2", "x_td", "0", "y_td", String.valueOf(Math.PI / 2), "gh_s", GeoHashUtils.encode(32.7693246, -78.9289094)));
- assertU(adoc("id", "3", "x_td", String.valueOf(Math.PI / 2), "y_td", String.valueOf(Math.PI / 2), "gh_s", GeoHashUtils.encode(32.7693246, -80.9289094)));
- assertU(adoc("id", "4", "x_td", String.valueOf(Math.PI / 4), "y_td", String.valueOf(Math.PI / 4), "gh_s", GeoHashUtils.encode(32.7693246, -81.9289094)));
+ assertU(adoc("id", "1", "x_td", "0", "y_td", "0", "gh_s1", GeoHashUtils.encode(32.7693246, -79.9289094)));
+ assertU(adoc("id", "2", "x_td", "0", "y_td", String.valueOf(Math.PI / 2), "gh_s1", GeoHashUtils.encode(32.7693246, -78.9289094)));
+ assertU(adoc("id", "3", "x_td", String.valueOf(Math.PI / 2), "y_td", String.valueOf(Math.PI / 2), "gh_s1", GeoHashUtils.encode(32.7693246, -80.9289094)));
+ assertU(adoc("id", "4", "x_td", String.valueOf(Math.PI / 4), "y_td", String.valueOf(Math.PI / 4), "gh_s1", GeoHashUtils.encode(32.7693246, -81.9289094)));
assertU(adoc("id", "5", "x_td", "45.0", "y_td", "45.0",
- "gh_s", GeoHashUtils.encode(32.7693246, -81.9289094)));
+ "gh_s1", GeoHashUtils.encode(32.7693246, -81.9289094)));
assertU(adoc("id", "6", "point_hash", "32.5, -79.0", "point", "32.5, -79.0"));
assertU(adoc("id", "7", "point_hash", "32.6, -78.0", "point", "32.6, -78.0"));
assertU(commit());
@@ -56,7 +56,7 @@ public class DistanceFunctionTest extend
//Geo Hash Haversine
//Can verify here: http://www.movable-type.co.uk/scripts/latlong.html, but they use a slightly different radius for the earth, so just be close
- assertQ(req("fl", "*,score", "q", "{!func}ghhsin(" + DistanceUtils.EARTH_MEAN_RADIUS_KM + ", gh_s, \"" + GeoHashUtils.encode(32, -79) +
+ assertQ(req("fl", "*,score", "q", "{!func}ghhsin(" + DistanceUtils.EARTH_MEAN_RADIUS_KM + ", gh_s1, \"" + GeoHashUtils.encode(32, -79) +
"\",)", "fq", "id:1"), "//float[@name='score']='122.171875'");
assertQ(req("fl", "id,point_hash,score", "q", "{!func}recip(ghhsin(" + DistanceUtils.EARTH_MEAN_RADIUS_KM + ", point_hash, \"" + GeoHashUtils.encode(32, -79) + "\"), 1, 1, 0)"),
@@ -66,7 +66,7 @@ public class DistanceFunctionTest extend
);
- assertQ(req("fl", "*,score", "q", "{!func}ghhsin(" + DistanceUtils.EARTH_MEAN_RADIUS_KM + ", gh_s, geohash(32, -79))", "fq", "id:1"), "//float[@name='score']='122.171875'");
+ assertQ(req("fl", "*,score", "q", "{!func}ghhsin(" + DistanceUtils.EARTH_MEAN_RADIUS_KM + ", gh_s1, geohash(32, -79))", "fq", "id:1"), "//float[@name='score']='122.171875'");
}
Modified: lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/spelling/suggest/SuggesterTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/spelling/suggest/SuggesterTest.java?rev=1081952&r1=1081951&r2=1081952&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/spelling/suggest/SuggesterTest.java (original)
+++ lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/spelling/suggest/SuggesterTest.java Tue Mar 15 21:35:17 2011
@@ -27,6 +27,7 @@ import org.apache.solr.util.TermFreqIter
import org.junit.BeforeClass;
import org.junit.Test;
+import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -65,6 +66,29 @@ public class SuggesterTest extends SolrT
@Test
public void testReload() throws Exception {
+ String leaveData = System.getProperty("solr.test.leavedatadir");
+ if (leaveData == null) leaveData = "";
+ System.setProperty("solr.test.leavedatadir", "true");
+ addDocs();
+ assertU(commit());
+ File data = dataDir;
+ String config = configString;
+ deleteCore();
+ dataDir = data;
+ configString = config;
+ initCore();
+ assertQ(req("qt","/suggest", "q","ac", SpellingParams.SPELLCHECK_COUNT, "2", SpellingParams.SPELLCHECK_ONLY_MORE_POPULAR, "true"),
+ "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='ac']/int[@name='numFound'][.='2']",
+ "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='ac']/arr[@name='suggestion']/str[1][.='acquire']",
+ "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='ac']/arr[@name='suggestion']/str[2][.='accommodate']"
+ );
+
+ // restore the property
+ System.setProperty("solr.test.leavedatadir", leaveData);
+ }
+
+ @Test
+ public void testRebuild() throws Exception {
addDocs();
assertU(commit());
assertQ(req("qt","/suggest", "q","ac", SpellingParams.SPELLCHECK_COUNT, "2", SpellingParams.SPELLCHECK_ONLY_MORE_POPULAR, "true"),
Modified: lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/update/DocumentBuilderTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/update/DocumentBuilderTest.java?rev=1081952&r1=1081951&r2=1081952&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/update/DocumentBuilderTest.java (original)
+++ lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/update/DocumentBuilderTest.java Tue Mar 15 21:35:17 2011
@@ -67,6 +67,40 @@ public class DocumentBuilderTest extends
}
@Test
+ public void testExceptions()
+ {
+ SolrCore core = h.getCore();
+
+ // make sure a null value is not indexed
+ SolrInputDocument doc = new SolrInputDocument();
+ doc.addField( "id", "123", 1.0f );
+ doc.addField( "unknown", "something", 1.0f );
+ try {
+ DocumentBuilder.toDocument( doc, core.getSchema() );
+ fail( "added an unknown field" );
+ }
+ catch( Exception ex ) {
+ assertTrue( "should have document ID", ex.getMessage().indexOf( "doc=123" ) > 0 );
+ }
+ doc.remove( "unknown" );
+
+
+ doc.addField( "weight", "not a number", 1.0f );
+ try {
+ DocumentBuilder.toDocument( doc, core.getSchema() );
+ fail( "invalid 'float' field value" );
+ }
+ catch( Exception ex ) {
+ assertTrue( "should have document ID", ex.getMessage().indexOf( "doc=123" ) > 0 );
+ assertTrue( "cause is number format", ex.getCause() instanceof NumberFormatException );
+ }
+
+ // now make sure it is OK
+ doc.setField( "weight", "1.34", 1.0f );
+ DocumentBuilder.toDocument( doc, core.getSchema() );
+ }
+
+ @Test
public void testMultiField() throws Exception {
SolrCore core = h.getCore();
Modified: lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/util/AbstractSolrTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/util/AbstractSolrTestCase.java?rev=1081952&r1=1081951&r2=1081952&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/util/AbstractSolrTestCase.java (original)
+++ lucene/dev/branches/bulkpostings/solr/src/test/org/apache/solr/util/AbstractSolrTestCase.java Tue Mar 15 21:35:17 2011
@@ -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 AbstractSolrTestCa
solrConfig,
getSchemaFile());
lrf = h.getRequestFactory
- ("standard",0,20,"version","2.2");
+ ("standard",0,20,CommonParams.VERSION,"2.2");
}
log.info("####SETUP_END " + getName());
}
Modified: lucene/dev/branches/bulkpostings/solr/src/webapp/src/org/apache/solr/servlet/SolrDispatchFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/solr/src/webapp/src/org/apache/solr/servlet/SolrDispatchFilter.java?rev=1081952&r1=1081951&r2=1081952&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/solr/src/webapp/src/org/apache/solr/servlet/SolrDispatchFilter.java (original)
+++ lucene/dev/branches/bulkpostings/solr/src/webapp/src/org/apache/solr/servlet/SolrDispatchFilter.java Tue Mar 15 21:35:17 2011
@@ -18,13 +18,17 @@
package org.apache.solr.servlet;
import java.io.IOException;
+import java.io.Writer;
import java.io.PrintWriter;
import java.io.StringWriter;
+import java.io.OutputStreamWriter;
import java.io.ByteArrayInputStream;
+import java.nio.charset.Charset;
import java.util.Map;
import java.util.WeakHashMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.xml.sax.InputSource;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
@@ -39,6 +43,8 @@ import org.apache.solr.common.SolrExcept
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.SimpleOrderedMap;
import org.apache.solr.common.params.CommonParams;
+import org.apache.solr.common.util.FastWriter;
+import org.apache.solr.common.util.ContentStreamBase;
import org.apache.solr.core.*;
import org.apache.solr.request.*;
import org.apache.solr.response.BinaryQueryResponseWriter;
@@ -62,10 +68,12 @@ public class SolrDispatchFilter implemen
protected String solrConfigFilename = null;
protected final Map<SolrConfig, SolrRequestParsers> parsers = new WeakHashMap<SolrConfig, SolrRequestParsers>();
protected final SolrRequestParsers adminRequestParser;
+
+ private static final Charset UTF8 = Charset.forName("UTF-8");
public SolrDispatchFilter() {
try {
- adminRequestParser = new SolrRequestParsers(new Config(null,"solr",new ByteArrayInputStream("<root/>".getBytes("UTF-8")),"") );
+ adminRequestParser = new SolrRequestParsers(new Config(null,"solr",new InputSource(new ByteArrayInputStream("<root/>".getBytes("UTF-8"))),"") );
} catch (Exception e) {
//unlikely
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,e);
@@ -318,14 +326,19 @@ public class SolrDispatchFilter implemen
final String ct = responseWriter.getContentType(solrReq, solrRsp);
// don't call setContentType on null
if (null != ct) response.setContentType(ct);
+
if (Method.HEAD != reqMethod) {
if (responseWriter instanceof BinaryQueryResponseWriter) {
BinaryQueryResponseWriter binWriter = (BinaryQueryResponseWriter) responseWriter;
binWriter.write(response.getOutputStream(), solrReq, solrRsp);
} else {
- PrintWriter out = response.getWriter();
+ String charset = ContentStreamBase.getCharsetFromContentType(ct);
+ Writer out = (charset == null || charset.equalsIgnoreCase("UTF-8"))
+ ? new OutputStreamWriter(response.getOutputStream(), UTF8)
+ : new OutputStreamWriter(response.getOutputStream(), charset);
+ out = new FastWriter(out);
responseWriter.write(out, solrReq, solrRsp);
-
+ out.flush();
}
}
//else http HEAD request, nothing to write out, waited this long just to get ContentType
Modified: lucene/dev/branches/bulkpostings/solr/src/webapp/web/admin/analysis.xsl
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/solr/src/webapp/web/admin/analysis.xsl?rev=1081952&r1=1081951&r2=1081952&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/solr/src/webapp/web/admin/analysis.xsl (original)
+++ lucene/dev/branches/bulkpostings/solr/src/webapp/web/admin/analysis.xsl Tue Mar 15 21:35:17 2011
@@ -26,7 +26,7 @@
method="html"
indent="yes"
encoding="utf-8"
- media-type="text/html; charset=UTF-8"
+ media-type="text/html"
doctype-public="-//W3C//DTD HTML 4.01//EN"
doctype-system="http://www.w3.org/TR/html4/strict.dtd" />
Modified: lucene/dev/branches/bulkpostings/solr/src/webapp/web/admin/meta.xsl
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/solr/src/webapp/web/admin/meta.xsl?rev=1081952&r1=1081951&r2=1081952&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/solr/src/webapp/web/admin/meta.xsl (original)
+++ lucene/dev/branches/bulkpostings/solr/src/webapp/web/admin/meta.xsl Tue Mar 15 21:35:17 2011
@@ -21,7 +21,7 @@
<xsl:output
method="html"
encoding="utf-8"
- media-type="text/html; charset=UTF-8"
+ media-type="text/html"
indent="yes"
doctype-public="-//W3C//DTD HTML 4.01//EN"
doctype-system="http://www.w3.org/TR/html4/strict.dtd" />
Modified: lucene/dev/branches/bulkpostings/solr/src/webapp/web/admin/registry.xsl
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/solr/src/webapp/web/admin/registry.xsl?rev=1081952&r1=1081951&r2=1081952&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/solr/src/webapp/web/admin/registry.xsl (original)
+++ lucene/dev/branches/bulkpostings/solr/src/webapp/web/admin/registry.xsl Tue Mar 15 21:35:17 2011
@@ -26,7 +26,7 @@
<xsl:output
method="html"
encoding="utf-8"
- media-type="text/html; charset=UTF-8"
+ media-type="text/html"
indent="yes"
doctype-public="-//W3C//DTD HTML 4.01//EN"
doctype-system="http://www.w3.org/TR/html4/strict.dtd" />
Modified: lucene/dev/branches/bulkpostings/solr/src/webapp/web/admin/stats.xsl
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/solr/src/webapp/web/admin/stats.xsl?rev=1081952&r1=1081951&r2=1081952&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/solr/src/webapp/web/admin/stats.xsl (original)
+++ lucene/dev/branches/bulkpostings/solr/src/webapp/web/admin/stats.xsl Tue Mar 15 21:35:17 2011
@@ -26,7 +26,7 @@
<xsl:output
method="html"
encoding="utf-8"
- media-type="text/html; charset=UTF-8"
+ media-type="text/html"
indent="yes"
doctype-public="-//W3C//DTD HTML 4.01//EN"
doctype-system="http://www.w3.org/TR/html4/strict.dtd" />
Modified: lucene/dev/branches/bulkpostings/solr/src/webapp/web/admin/tabular.xsl
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/solr/src/webapp/web/admin/tabular.xsl?rev=1081952&r1=1081951&r2=1081952&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/solr/src/webapp/web/admin/tabular.xsl (original)
+++ lucene/dev/branches/bulkpostings/solr/src/webapp/web/admin/tabular.xsl Tue Mar 15 21:35:17 2011
@@ -27,7 +27,7 @@
<xsl:output
method="html"
encoding="utf-8"
- media-type="text/html; charset=UTF-8"
+ media-type="text/html"
indent="yes"
doctype-public="-//W3C//DTD HTML 4.01//EN"
doctype-system="http://www.w3.org/TR/html4/strict.dtd" />
Modified: lucene/dev/branches/bulkpostings/solr/src/webapp/web/admin/threaddump.xsl
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/solr/src/webapp/web/admin/threaddump.xsl?rev=1081952&r1=1081951&r2=1081952&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/solr/src/webapp/web/admin/threaddump.xsl (original)
+++ lucene/dev/branches/bulkpostings/solr/src/webapp/web/admin/threaddump.xsl Tue Mar 15 21:35:17 2011
@@ -26,7 +26,7 @@
method="html"
indent="yes"
encoding="utf-8"
- media-type="text/html; charset=UTF-8"
+ media-type="text/html"
doctype-public="-//W3C//DTD HTML 4.01//EN"
doctype-system="http://www.w3.org/TR/html4/strict.dtd" />