You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by si...@apache.org on 2011/04/23 10:07:32 UTC
svn commit: r1096120 [3/3] - in /lucene/dev/branches/realtime_search: ./
lucene/ lucene/contrib/ lucene/contrib/db/bdb-je/lib/
lucene/contrib/db/bdb/lib/
lucene/contrib/highlighter/src/java/org/apache/lucene/search/highlight/
lucene/contrib/highlighter...
Modified: lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/search/function/distance/GeohashHaversineFunction.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/search/function/distance/GeohashHaversineFunction.java?rev=1096120&r1=1096119&r2=1096120&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/search/function/distance/GeohashHaversineFunction.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/search/function/distance/GeohashHaversineFunction.java Sat Apr 23 08:07:28 2011
@@ -18,6 +18,7 @@ package org.apache.solr.search.function.
import org.apache.lucene.spatial.DistanceUtils;
+import org.apache.solr.search.function.DoubleDocValues;
import org.apache.solr.search.function.ValueSource;
import org.apache.solr.search.function.DocValues;
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
@@ -58,32 +59,11 @@ public class GeohashHaversineFunction ex
final DocValues gh1DV = geoHash1.getValues(context, readerContext);
final DocValues gh2DV = geoHash2.getValues(context, readerContext);
- return new DocValues() {
- @Override
- public float floatVal(int doc) {
- return (float) doubleVal(doc);
- }
-
- @Override
- public int intVal(int doc) {
- return (int) doubleVal(doc);
- }
-
- @Override
- public long longVal(int doc) {
- return (long) doubleVal(doc);
- }
-
+ return new DoubleDocValues(this) {
@Override
public double doubleVal(int doc) {
return distance(doc, gh1DV, gh2DV);
}
-
- @Override
- public String strVal(int doc) {
- return Double.toString(doubleVal(doc));
- }
-
@Override
public String toString(int doc) {
StringBuilder sb = new StringBuilder();
Modified: lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/search/function/distance/HaversineConstFunction.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/search/function/distance/HaversineConstFunction.java?rev=1096120&r1=1096119&r2=1096120&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/search/function/distance/HaversineConstFunction.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/search/function/distance/HaversineConstFunction.java Sat Apr 23 08:07:28 2011
@@ -198,22 +198,7 @@ public class HaversineConstFunction exte
final double lonCenterRad = this.lonCenter * DistanceUtils.DEGREES_TO_RADIANS;
final double latCenterRad_cos = this.latCenterRad_cos;
- return new DocValues() {
- @Override
- public float floatVal(int doc) {
- return (float) doubleVal(doc);
- }
-
- @Override
- public int intVal(int doc) {
- return (int) doubleVal(doc);
- }
-
- @Override
- public long longVal(int doc) {
- return (long) doubleVal(doc);
- }
-
+ return new DoubleDocValues(this) {
@Override
public double doubleVal(int doc) {
double latRad = latVals.doubleVal(doc) * DistanceUtils.DEGREES_TO_RADIANS;
@@ -226,12 +211,6 @@ public class HaversineConstFunction exte
(latCenterRad_cos * Math.cos(latRad) * hsinY * hsinY);
return (EARTH_MEAN_DIAMETER * Math.atan2(Math.sqrt(h), Math.sqrt(1 - h)));
}
-
- @Override
- public String strVal(int doc) {
- return Double.toString(doubleVal(doc));
- }
-
@Override
public String toString(int doc) {
return name() + '(' + latVals.toString(doc) + ',' + lonVals.toString(doc) + ',' + latCenter + ',' + lonCenter + ')';
Modified: lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/search/function/distance/HaversineFunction.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/search/function/distance/HaversineFunction.java?rev=1096120&r1=1096119&r2=1096120&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/search/function/distance/HaversineFunction.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/search/function/distance/HaversineFunction.java Sat Apr 23 08:07:28 2011
@@ -20,6 +20,7 @@ import org.apache.lucene.index.IndexRead
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.spatial.DistanceUtils;
import org.apache.solr.common.SolrException;
+import org.apache.solr.search.function.DoubleDocValues;
import org.apache.solr.search.function.MultiValueSource;
import org.apache.solr.search.function.DocValues;
import org.apache.solr.search.function.ValueSource;
@@ -99,32 +100,11 @@ public class HaversineFunction extends V
final DocValues vals1 = p1.getValues(context, readerContext);
final DocValues vals2 = p2.getValues(context, readerContext);
- return new DocValues() {
- @Override
- public float floatVal(int doc) {
- return (float) doubleVal(doc);
- }
-
- @Override
- public int intVal(int doc) {
- return (int) doubleVal(doc);
- }
-
- @Override
- public long longVal(int doc) {
- return (long) doubleVal(doc);
- }
-
+ return new DoubleDocValues(this) {
@Override
public double doubleVal(int doc) {
return distance(doc, vals1, vals2);
}
-
- @Override
- public String strVal(int doc) {
- return Double.toString(doubleVal(doc));
- }
-
@Override
public String toString(int doc) {
StringBuilder sb = new StringBuilder();
Modified: lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/search/function/distance/StringDistanceFunction.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/search/function/distance/StringDistanceFunction.java?rev=1096120&r1=1096119&r2=1096120&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/search/function/distance/StringDistanceFunction.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/search/function/distance/StringDistanceFunction.java Sat Apr 23 08:07:28 2011
@@ -20,6 +20,7 @@ package org.apache.solr.search.function.
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
import org.apache.lucene.search.spell.StringDistance;
import org.apache.solr.search.function.DocValues;
+import org.apache.solr.search.function.FloatDocValues;
import org.apache.solr.search.function.ValueSource;
import java.io.IOException;
@@ -51,7 +52,7 @@ public class StringDistanceFunction exte
public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
final DocValues str1DV = str1.getValues(context, readerContext);
final DocValues str2DV = str2.getValues(context, readerContext);
- return new DocValues() {
+ return new FloatDocValues(this) {
@Override
public float floatVal(int doc) {
@@ -59,21 +60,6 @@ public class StringDistanceFunction exte
}
@Override
- public int intVal(int doc) {
- return (int) doubleVal(doc);
- }
-
- @Override
- public long longVal(int doc) {
- return (long) doubleVal(doc);
- }
-
- @Override
- public double doubleVal(int doc) {
- return (double) floatVal(doc);
- }
-
- @Override
public String toString(int doc) {
StringBuilder sb = new StringBuilder();
sb.append("strdist").append('(');
Modified: lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/search/function/distance/VectorDistanceFunction.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/search/function/distance/VectorDistanceFunction.java?rev=1096120&r1=1096119&r2=1096120&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/search/function/distance/VectorDistanceFunction.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/search/function/distance/VectorDistanceFunction.java Sat Apr 23 08:07:28 2011
@@ -21,6 +21,7 @@ import org.apache.lucene.search.IndexSea
import org.apache.lucene.spatial.DistanceUtils;
import org.apache.solr.common.SolrException;
import org.apache.solr.search.function.DocValues;
+import org.apache.solr.search.function.DoubleDocValues;
import org.apache.solr.search.function.MultiValueSource;
import org.apache.solr.search.function.ValueSource;
@@ -85,31 +86,7 @@ public class VectorDistanceFunction exte
final DocValues vals2 = source2.getValues(context, readerContext);
- return new DocValues() {
- @Override
- public byte byteVal(int doc) {
- return (byte) doubleVal(doc);
- }
-
- @Override
- public short shortVal(int doc) {
- return (short) doubleVal(doc);
- }
-
- @Override
- public float floatVal(int doc) {
- return (float) doubleVal(doc);
- }
-
- @Override
- public int intVal(int doc) {
- return (int) doubleVal(doc);
- }
-
- @Override
- public long longVal(int doc) {
- return (long) doubleVal(doc);
- }
+ return new DoubleDocValues(this) {
@Override
public double doubleVal(int doc) {
@@ -117,11 +94,6 @@ public class VectorDistanceFunction exte
}
@Override
- public String strVal(int doc) {
- return Double.toString(doubleVal(doc));
- }
-
- @Override
public String toString(int doc) {
StringBuilder sb = new StringBuilder();
sb.append(name()).append('(').append(power).append(',');
Modified: lucene/dev/branches/realtime_search/solr/src/solrj/org/apache/solr/client/solrj/impl/CommonsHttpSolrServer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/solrj/org/apache/solr/client/solrj/impl/CommonsHttpSolrServer.java?rev=1096120&r1=1096119&r2=1096120&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/solrj/org/apache/solr/client/solrj/impl/CommonsHttpSolrServer.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/solrj/org/apache/solr/client/solrj/impl/CommonsHttpSolrServer.java Sat Apr 23 08:07:28 2011
@@ -26,15 +26,7 @@ import java.util.*;
import java.util.zip.GZIPInputStream;
import java.util.zip.InflaterInputStream;
-import org.apache.commons.httpclient.Header;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpConnectionManager;
-import org.apache.commons.httpclient.HttpException;
-import org.apache.commons.httpclient.HttpMethod;
-import org.apache.commons.httpclient.HttpMethodBase;
-import org.apache.commons.httpclient.HttpStatus;
-import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
-import org.apache.commons.httpclient.NoHttpResponseException;
+import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
import org.apache.commons.httpclient.methods.PostMethod;
@@ -43,6 +35,7 @@ import org.apache.commons.httpclient.met
import org.apache.commons.httpclient.methods.multipart.Part;
import org.apache.commons.httpclient.methods.multipart.PartBase;
import org.apache.commons.httpclient.methods.multipart.StringPart;
+import org.apache.commons.httpclient.params.HttpMethodParams;
import org.apache.commons.io.IOUtils;
import org.apache.solr.client.solrj.ResponseParser;
import org.apache.solr.client.solrj.SolrRequest;
@@ -205,15 +198,21 @@ public class CommonsHttpSolrServer exten
if( _baseURL.indexOf( '?' ) >=0 ) {
throw new RuntimeException( "Invalid base url for solrj. The base URL must not contain parameters: "+_baseURL );
}
-
- _httpClient = (client == null) ? new HttpClient(new MultiThreadedHttpConnectionManager()) : client;
if (client == null) {
+ _httpClient = new HttpClient(new MultiThreadedHttpConnectionManager()) ;
+
+ // prevent retries (note: this didn't work when set on mgr.. needed to be set on client)
+ DefaultHttpMethodRetryHandler retryhandler = new DefaultHttpMethodRetryHandler(0, false);
+ _httpClient.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, retryhandler);
+
// set some better defaults if we created a new connection manager and client
-
+
// increase the default connections
this.setDefaultMaxConnectionsPerHost( 32 ); // 2
this.setMaxTotalConnections( 128 ); // 20
+ } else {
+ _httpClient = client;
}
_parser = parser;
Modified: lucene/dev/branches/realtime_search/solr/src/test-files/solr/shared/solr.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test-files/solr/shared/solr.xml?rev=1096120&r1=1096119&r2=1096120&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test-files/solr/shared/solr.xml (original)
+++ lucene/dev/branches/realtime_search/solr/src/test-files/solr/shared/solr.xml Sat Apr 23 08:07:28 2011
@@ -30,7 +30,7 @@
adminPath: RequestHandler path to manage cores.
If 'null' (or absent), cores will not be manageable via REST
-->
- <cores adminPath="/admin/cores" defaultCoreName="core0">
+ <cores adminPath="/admin/cores" defaultCoreName="core0" host="127.0.0.1" hostPort="${hostPort:8983}" hostContext="solr" zkClientTimeout="8000">
<core name="core0" instanceDir="./">
<property name="version" value="3.5"/>
<property name="l10n" value="EN"/>
Modified: lucene/dev/branches/realtime_search/solr/src/test-framework/org/apache/solr/BaseDistributedSearchTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test-framework/org/apache/solr/BaseDistributedSearchTestCase.java?rev=1096120&r1=1096119&r2=1096120&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test-framework/org/apache/solr/BaseDistributedSearchTestCase.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/test-framework/org/apache/solr/BaseDistributedSearchTestCase.java Sat Apr 23 08:07:28 2011
@@ -323,12 +323,15 @@ public abstract class BaseDistributedSea
protected void query(Object... q) throws Exception {
final ModifiableSolrParams params = new ModifiableSolrParams();
+ params.add("reqid",Integer.toString(random.nextInt())); // just to help correlate top-level requests w/ sub requests
for (int i = 0; i < q.length; i += 2) {
params.add(q[i].toString(), q[i + 1].toString());
}
+ params.add("controlClient","true"); // just to enable easier sorting through log files
final QueryResponse controlRsp = controlClient.query(params);
+ params.remove("controlClient");
setDistributedParams(params);
@@ -418,7 +421,7 @@ public abstract class BaseDistributedSea
break;
}
if (ordered) {
- return "." + namea + "!=" + nameb + " (unordered or missing)";
+ return err("." + namea + "!=" + nameb + " (unordered or missing)");
}
// if unordered, continue until we find the right field.
}
@@ -432,7 +435,7 @@ public abstract class BaseDistributedSea
if (a.size() - aSkipped != b.size() - bSkipped) {
- return ".size()==" + a.size() + "," + b.size() + "skipped=" + aSkipped + "," + bSkipped;
+ return err(".size()==" + a.size() + "," + b.size() + "skipped=" + aSkipped + "," + bSkipped);
}
return null;
@@ -446,7 +449,7 @@ public abstract class BaseDistributedSea
int flagsa = flags(handle, keya);
if ((flagsa & SKIP) != 0) continue;
if (!b.containsKey(keya)) {
- return "[" + keya + "]==null";
+ return err("[" + keya + "]==null");
}
if ((flagsa & SKIPVAL) != 0) continue;
Object valb = b.get(keya);
@@ -478,7 +481,7 @@ public abstract class BaseDistributedSea
} else {
if (b.getMaxScore() != null) {
if (a.getMaxScore() == null) {
- return ".maxScore missing";
+ return err(".maxScore missing");
}
}
}
@@ -524,7 +527,7 @@ public abstract class BaseDistributedSea
public static String compare(Object[] a, Object[] b, int flags, Map<String, Integer> handle) {
if (a.length != b.length) {
- return ".length:" + a.length + "!=" + b.length;
+ return err(".length:" + a.length + "!=" + b.length);
}
for (int i = 0; i < a.length; i++) {
String cmp = compare(a[i], b[i], flags, handle);
@@ -535,7 +538,7 @@ public abstract class BaseDistributedSea
public static String compare(Object a, Object b, int flags, Map<String, Integer> handle) {
if (a == b) return null;
- if (a == null || b == null) return ":" + a + "!=" + b;
+ if (a == null || b == null) return err(":" + a + "!=" + b);
if (a instanceof NamedList && b instanceof NamedList) {
return compare((NamedList) a, (NamedList) b, flags, handle);
@@ -559,7 +562,7 @@ public abstract class BaseDistributedSea
if (a instanceof byte[] && b instanceof byte[]) {
if (!Arrays.equals((byte[]) a, (byte[]) b)) {
- return ":" + a + "!=" + b;
+ return err(":" + a + "!=" + b);
}
return null;
}
@@ -570,12 +573,19 @@ public abstract class BaseDistributedSea
}
if (!(a.equals(b))) {
- return ":" + a + "!=" + b;
+ return err(":" + a + "!=" + b);
}
return null;
}
+ /** This method is called for root level comparison errors and can be helpful to set a
+ * breakpoint in to debug comparison failures.
+ */
+ public static String err(String msg) {
+ return msg;
+ }
+
protected void compareResponses(QueryResponse a, QueryResponse b) {
String cmp;
cmp = compare(a.getResponse(), b.getResponse(), flags, handle);
Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/TestDistributedSearch.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/TestDistributedSearch.java?rev=1096120&r1=1096119&r2=1096120&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/TestDistributedSearch.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/TestDistributedSearch.java Sat Apr 23 08:07:28 2011
@@ -40,7 +40,8 @@ public class TestDistributedSearch exten
String nlong = "n_l";
String tlong = "other_tl1";
String ndate = "n_dt";
- String tdate = "n_tdt";
+ String tdate_a = "a_n_tdt";
+ String tdate_b = "b_n_tdt";
String oddField="oddField_s";
String missingField="ignore_exception__missing_but_valid_field_t";
@@ -48,25 +49,40 @@ public class TestDistributedSearch exten
@Override
public void doTest() throws Exception {
+ int backupStress = stress; // make a copy so we can restore
+
+
del("*:*");
- indexr(id,1, i1, 100, tlong, 100,t1,"now is the time for all good men"
- ,"foo_f", 1.414f, "foo_b", "true", "foo_d", 1.414d);
- indexr(id,2, i1, 50 , tlong, 50,t1,"to come to the aid of their country."
- );
- indexr(id,3, i1, 2, tlong, 2,t1,"how now brown cow"
- );
- indexr(id,4, i1, -100 ,tlong, 101,t1,"the quick fox jumped over the lazy dog"
- );
- indexr(id,5, i1, 500, tlong, 500 ,t1,"the quick fox jumped way over the lazy dog"
- );
+ indexr(id,1, i1, 100, tlong, 100,t1,"now is the time for all good men",
+ tdate_a, "2010-04-20T11:00:00Z",
+ tdate_b, "2009-08-20T11:00:00Z",
+ "foo_f", 1.414f, "foo_b", "true", "foo_d", 1.414d);
+ indexr(id,2, i1, 50 , tlong, 50,t1,"to come to the aid of their country.",
+ tdate_a, "2010-05-02T11:00:00Z",
+ tdate_b, "2009-11-02T11:00:00Z");
+ indexr(id,3, i1, 2, tlong, 2,t1,"how now brown cow",
+ tdate_a, "2010-05-03T11:00:00Z");
+ indexr(id,4, i1, -100 ,tlong, 101,
+ t1,"the quick fox jumped over the lazy dog",
+ tdate_a, "2010-05-03T11:00:00Z",
+ tdate_b, "2010-05-03T11:00:00Z");
+ indexr(id,5, i1, 500, tlong, 500 ,
+ t1,"the quick fox jumped way over the lazy dog",
+ tdate_a, "2010-05-05T11:00:00Z");
indexr(id,6, i1, -600, tlong, 600 ,t1,"humpty dumpy sat on a wall");
indexr(id,7, i1, 123, tlong, 123 ,t1,"humpty dumpy had a great fall");
- indexr(id,8, i1, 876, tlong, 876,t1,"all the kings horses and all the kings men");
+ indexr(id,8, i1, 876, tlong, 876,
+ tdate_b, "2010-01-05T11:00:00Z",
+ t1,"all the kings horses and all the kings men");
indexr(id,9, i1, 7, tlong, 7,t1,"couldn't put humpty together again");
indexr(id,10, i1, 4321, tlong, 4321,t1,"this too shall pass");
- indexr(id,11, i1, -987, tlong, 987,t1,"An eye for eye only ends up making the whole world blind.");
- indexr(id,12, i1, 379, tlong, 379,t1,"Great works are performed, not by strength, but by perseverance.");
- indexr(id,13, i1, 232, tlong, 232,t1,"no eggs on wall, lesson learned", oddField, "odd man out");
+ indexr(id,11, i1, -987, tlong, 987,
+ t1,"An eye for eye only ends up making the whole world blind.");
+ indexr(id,12, i1, 379, tlong, 379,
+ t1,"Great works are performed, not by strength, but by perseverance.");
+ indexr(id,13, i1, 232, tlong, 232,
+ t1,"no eggs on wall, lesson learned",
+ oddField, "odd man out");
indexr(id, 14, "SubjectTerms_mfacet", new String[] {"mathematical models", "mathematical analysis"});
indexr(id, 15, "SubjectTerms_mfacet", new String[] {"test 1", "test 2", "test3"});
@@ -132,23 +148,73 @@ public class TestDistributedSearch exten
// then the primary sort should always be a tie and then the secondary should always decide
query("q","{!func}ms(NOW)", "sort","score desc,"+i1+" desc","fl","id");
- query("q","*:*", "rows",100, "facet","true", "facet.field",t1);
- query("q","*:*", "rows",100, "facet","true", "facet.field",t1, "facet.limit",-1, "facet.sort","count");
- 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);
- query("q","*:*", "rows",100, "facet","true", "facet.field",t1, "facet.mincount",2);
+ query("q","*:*", "rows",0, "facet","true", "facet.field",t1);
+ query("q","*:*", "rows",0, "facet","true", "facet.field",t1,"facet.limit",1);
+ query("q","*:*", "rows",0, "facet","true", "facet.query","quick", "facet.query","all", "facet.query","*:*");
+ query("q","*:*", "rows",0, "facet","true", "facet.field",t1, "facet.mincount",2);
+
+ // simple date facet on one field
+ query("q","*:*", "rows",100, "facet","true",
+ "facet.date",tdate_a,
+ "facet.date.other", "all",
+ "facet.date.start","2010-05-01T11:00:00Z",
+ "facet.date.gap","+1DAY",
+ "facet.date.end","2010-05-20T11:00:00Z");
+
+ // date facet on multiple fields
+ query("q","*:*", "rows",100, "facet","true",
+ "facet.date",tdate_a,
+ "facet.date",tdate_b,
+ "facet.date.other", "all",
+ "f."+tdate_b+".facet.date.start","2009-05-01T11:00:00Z",
+ "f."+tdate_b+".facet.date.gap","+3MONTHS",
+ "facet.date.start","2010-05-01T11:00:00Z",
+ "facet.date.gap","+1DAY",
+ "facet.date.end","2010-05-20T11:00:00Z");
+
+ // simple range facet on one field
+ query("q","*:*", "rows",100, "facet","true",
+ "facet.range",tlong,
+ "facet.range.start",200,
+ "facet.range.gap",100,
+ "facet.range.end",900);
+
+ // range facet on multiple fields
+ query("q","*:*", "rows",100, "facet","true",
+ "facet.range",tlong,
+ "facet.range",i1,
+ "f."+i1+".facet.range.start",300,
+ "f."+i1+".facet.range.gap",87,
+ "facet.range.end",900,
+ "facet.range.start",200,
+ "facet.range.gap",100,
+ "f."+tlong+".facet.range.end",900);
+
+ stress=0; // turn off stress... we want to tex max combos in min time
+ for (int i=0; i<25*RANDOM_MULTIPLIER; i++) {
+ String f = fieldNames[random.nextInt(fieldNames.length)];
+ if (random.nextBoolean()) f = t1; // the text field is a really interesting one to facet on (and it's multi-valued too)
+
+ // we want a random query and not just *:* so we'll get zero counts in facets also
+ // TODO: do a better random query
+ String q = random.nextBoolean() ? "*:*" : "id:(1 3 5 7 9 11 13) OR id:[100 TO " + random.nextInt(50) + "]";
+
+ int nolimit = random.nextBoolean() ? -1 : 10000; // these should be equivalent
+
+ // if limit==-1, we should always get exact matches
+ query("q",q, "rows",0, "facet","true", "facet.field",f, "facet.limit",nolimit, "facet.sort","count", "facet.mincount",random.nextInt(5), "facet.offset",random.nextInt(10));
+ query("q",q, "rows",0, "facet","true", "facet.field",f, "facet.limit",nolimit, "facet.sort","index", "facet.mincount",random.nextInt(5), "facet.offset",random.nextInt(10));
+ // for index sort, we should get exact results for mincount <= 1
+ query("q",q, "rows",0, "facet","true", "facet.field",f, "facet.sort","index", "facet.mincount",random.nextInt(2), "facet.offset",random.nextInt(10), "facet.limit",random.nextInt(11)-1);
+ }
+ stress = backupStress; // restore stress
// test faceting multiple things at once
- query("q","*:*", "rows",100, "facet","true", "facet.query","quick", "facet.query","all", "facet.query","*:*"
+ query("q","*:*", "rows",0, "facet","true", "facet.query","quick", "facet.query","all", "facet.query","*:*"
,"facet.field",t1);
// test filter tagging, facet exclusion, and naming (multi-select facet support)
- query("q","*:*", "rows",100, "facet","true", "facet.query","{!key=myquick}quick", "facet.query","{!key=myall ex=a}all", "facet.query","*:*"
+ query("q","*:*", "rows",0, "facet","true", "facet.query","{!key=myquick}quick", "facet.query","{!key=myall ex=a}all", "facet.query","*:*"
,"facet.field","{!key=mykey ex=a}"+t1
,"facet.field","{!key=other ex=b}"+t1
,"facet.field","{!key=again ex=a,b}"+t1
Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/embedded/TestSolrProperties.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/embedded/TestSolrProperties.java?rev=1096120&r1=1096119&r2=1096120&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/embedded/TestSolrProperties.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/embedded/TestSolrProperties.java Sat Apr 23 08:07:28 2011
@@ -70,11 +70,13 @@ public class TestSolrProperties extends
@Before
public void setUp() throws Exception {
super.setUp();
+ System.setProperty("solr.solr.home", getSolrHome());
+
File home = SolrTestCaseJ4.getFile(getSolrHome());
System.setProperty("solr.solr.home", home.getAbsolutePath());
log.info("pwd: " + (new File(".")).getAbsolutePath());
- solrXml = new File(home, "solr.xml");
+ solrXml = new File(home, getSolrXml());
cores = new CoreContainer(home.getAbsolutePath(), solrXml);
}
@@ -109,6 +111,10 @@ public class TestSolrProperties extends
protected SolrServer getSolrAdmin() {
return new EmbeddedSolrServer(cores, "core0");
}
+
+ protected SolrServer getRenamedSolrAdmin() {
+ return new EmbeddedSolrServer(cores, "renamed_core");
+ }
protected SolrServer getSolrCore(String name) {
return new EmbeddedSolrServer(cores, name);
@@ -187,16 +193,31 @@ public class TestSolrProperties extends
mcr = CoreAdminRequest.persist("solr-persist.xml", coreadmin);
- // System.out.println(IOUtils.toString(new FileInputStream(new File(solrXml.getParent(), "solr-persist.xml"))));
+ //System.out.println(IOUtils.toString(new FileInputStream(new File(solrXml.getParent(), "solr-persist.xml"))));
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
FileInputStream fis = new FileInputStream(new File(solrXml.getParent(), "solr-persist.xml"));
try {
Document document = builder.parse(fis);
assertTrue(exists("/solr/cores[@defaultCoreName='core0']", document));
+ assertTrue(exists("/solr/cores[@host='127.0.0.1']", document));
+ assertTrue(exists("/solr/cores[@hostPort='8983']", document));
+ assertTrue(exists("/solr/cores[@zkClientTimeout='8000']", document));
+ assertTrue(exists("/solr/cores[@hostContext='solr']", document));
+
+ } finally {
+ fis.close();
+ }
+
+ CoreAdminRequest.renameCore(name, "renamed_core", coreadmin);
+ mcr = CoreAdminRequest.persist("solr-persist.xml", getRenamedSolrAdmin());
+
+ fis = new FileInputStream(new File(solrXml.getParent(), "solr-persist.xml"));
+ try {
+ Document document = builder.parse(fis);
+ assertTrue(exists("/solr/cores/core[@name='renamed_core']", document));
} finally {
fis.close();
}
-
}
public static boolean exists(String xpathStr, Node node)
Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/search/QueryParsingTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/search/QueryParsingTest.java?rev=1096120&r1=1096119&r2=1096120&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/search/QueryParsingTest.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/search/QueryParsingTest.java Sat Apr 23 08:07:28 2011
@@ -99,15 +99,15 @@ public class QueryParsingTest extends So
assertEquals(flds[0].getType(), SortField.CUSTOM);
//Not thrilled about the fragility of string matching here, but...
//the value sources get wrapped, so the out field is different than the input
- assertEquals(flds[0].getField(), "pow(float(weight),const(2.0))");
+ assertEquals(flds[0].getField(), "pow(float(weight),const(2))");
//test functions (more deep)
- sort = QueryParsing.parseSort("sum(product(r_f1,sum(d_f1,t_f1,1)),a_f1) asc", req);
+ sort = QueryParsing.parseSort("sum(product(r_f1,sum(d_f1,t_f1,1.0)),a_f1) asc", req);
flds = sort.getSort();
assertEquals(flds[0].getType(), SortField.CUSTOM);
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);
+ sort = QueryParsing.parseSort("pow(weight, 2.0) desc", req);
flds = sort.getSort();
assertEquals(flds[0].getType(), SortField.CUSTOM);
//Not thrilled about the fragility of string matching here, but...
@@ -115,7 +115,7 @@ public class QueryParsingTest extends So
assertEquals(flds[0].getField(), "pow(float(weight),const(2.0))");
- sort = QueryParsing.parseSort("pow(weight, 2) desc, weight desc, bday asc", req);
+ sort = QueryParsing.parseSort("pow(weight, 2.0) desc, weight desc, bday asc", req);
flds = sort.getSort();
assertEquals(flds[0].getType(), SortField.CUSTOM);
Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/search/TestExtendedDismaxParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/search/TestExtendedDismaxParser.java?rev=1096120&r1=1096119&r2=1096120&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/search/TestExtendedDismaxParser.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/search/TestExtendedDismaxParser.java Sat Apr 23 08:07:28 2011
@@ -49,8 +49,13 @@ public class TestExtendedDismaxParser ex
"name", "The Zapper"));
assertU(adoc("id", "45", "trait_ss", "Chauvinist",
"title", "25 star General"));
- assertU(adoc("id", "46", "trait_ss", "Obnoxious",
- "subject", "Defeated the pacifists op the Gandhi nebula"));
+ assertU(adoc("id", "46",
+ "trait_ss", "Obnoxious",
+ "subject", "Defeated the pacifists op the Gandhi nebula",
+ "t_special", "literal:colon value",
+ "movies_t", "first is Mission: Impossible, second is Terminator 2: Judgement Day. Terminator:3 ok...",
+ "foo_i", "8"
+ ));
assertU(adoc("id", "47", "trait_ss", "Pig",
"text", "line up and fly directly at the enemy death cannons, clogging them with wreckage!"));
assertU(adoc("id", "48", "text_sw", "this has gigabyte potential", "foo_i","100"));
@@ -64,6 +69,11 @@ public class TestExtendedDismaxParser ex
String twor = "*[count(//doc)=2]";
String nor = "*[count(//doc)=0]";
+ assertQ("expected doc is missing (using un-escaped edismax w/qf)",
+ req("q", "literal:colon",
+ "qf", "t_special",
+ "defType", "edismax"),
+ "//doc[1]/str[@name='id'][.='46']");
assertQ("standard request handler returns all matches",
req(allq),
@@ -164,6 +174,58 @@ public class TestExtendedDismaxParser ex
"q","the big"), oner
);
+ // searching for a literal colon value when clearly not used for a field
+ assertQ("expected doc is missing (using standard)",
+ req("q", "t_special:literal\\:colon"),
+ "//doc[1]/str[@name='id'][.='46']");
+ assertQ("expected doc is missing (using escaped edismax w/field)",
+ req("q", "t_special:literal\\:colon",
+ "defType", "edismax"),
+ "//doc[1]/str[@name='id'][.='46']");
+ assertQ("expected doc is missing (using un-escaped edismax w/field)",
+ req("q", "t_special:literal:colon",
+ "defType", "edismax"),
+ "//doc[1]/str[@name='id'][.='46']");
+ assertQ("expected doc is missing (using escaped edismax w/qf)",
+ req("q", "literal\\:colon",
+ "qf", "t_special",
+ "defType", "edismax"),
+ "//doc[1]/str[@name='id'][.='46']");
+ assertQ("expected doc is missing (using un-escaped edismax w/qf)",
+ req("q", "literal:colon",
+ "qf", "t_special",
+ "defType", "edismax"),
+ "//doc[1]/str[@name='id'][.='46']");
+
+ assertQ(req("defType","edismax", "mm","100%", "q","terminator:3", "qf","movies_t"),
+ oner);
+ assertQ(req("defType","edismax", "mm","100%", "q","Mission:Impossible", "qf","movies_t"),
+ oner);
+ assertQ(req("defType","edismax", "mm","100%", "q","Mission : Impossible", "qf","movies_t"),
+ oner);
+ assertQ(req("defType","edismax", "mm","100%", "q","Mission: Impossible", "qf","movies_t"),
+ oner);
+ assertQ(req("defType","edismax", "mm","100%", "q","Terminator 2: Judgement Day", "qf","movies_t"),
+ oner);
+
+ // make sure the clause wasn't eliminated
+ assertQ(req("defType","edismax", "mm","100%", "q","Terminator 10: Judgement Day", "qf","movies_t"),
+ nor);
+
+ // throw in a numeric field
+ assertQ(req("defType","edismax", "mm","0", "q","Terminator: 100", "qf","movies_t foo_i"),
+ twor);
+
+ assertQ(req("defType","edismax", "mm","100%", "q","Terminator: 100", "qf","movies_t foo_i"),
+ nor);
+
+ assertQ(req("defType","edismax", "mm","100%", "q","Terminator: 8", "qf","movies_t foo_i"),
+ oner);
+
+ assertQ(req("defType","edismax", "mm","0", "q","movies_t:Terminator 100", "qf","movies_t foo_i"),
+ twor);
+
+
/** stopword removal in conjunction with multi-word synonyms at query time
* break this test.
// multi-word synonyms
Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/search/TestQueryTypes.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/search/TestQueryTypes.java?rev=1096120&r1=1096119&r2=1096120&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/search/TestQueryTypes.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/search/TestQueryTypes.java Sat Apr 23 08:07:28 2011
@@ -43,6 +43,7 @@ public class TestQueryTypes extends Abst
public void testQueryTypes() {
+ assertU(adoc("id","0"));
assertU(adoc("id","1", "v_t","Hello Dude"));
assertU(adoc("id","2", "v_t","Hello Yonik"));
assertU(adoc("id","3", "v_s","{!literal}"));
@@ -120,6 +121,7 @@ public class TestQueryTypes extends Abst
);
// function query... just make sure it doesn't throw an exception
+ if ("v_s".equals(f)) continue; // in this context, functions must be able to be interpreted as a float
assertQ(req( "q", "+id:999 _val_:\"" + f + "\"")
,"//result[@numFound='1']"
);
Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/update/processor/SignatureUpdateProcessorFactoryTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/update/processor/SignatureUpdateProcessorFactoryTest.java?rev=1096120&r1=1096119&r2=1096120&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/update/processor/SignatureUpdateProcessorFactoryTest.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/update/processor/SignatureUpdateProcessorFactoryTest.java Sat Apr 23 08:07:28 2011
@@ -43,7 +43,7 @@ import org.junit.Test;
public class SignatureUpdateProcessorFactoryTest extends SolrTestCaseJ4 {
/** modified by tests as needed */
- private String processor = "dedupe";
+ private String chain = "dedupe";
@BeforeClass
public static void beforeClass() throws Exception {
@@ -56,7 +56,7 @@ public class SignatureUpdateProcessorFac
super.setUp();
clearIndex();
assertU(commit());
- processor = "dedupe"; // set the default that most tests expect
+ chain = "dedupe"; // set the default that most tests expect
}
void checkNumDocs(int n) {
@@ -203,7 +203,7 @@ public class SignatureUpdateProcessorFac
checkNumDocs(0);
- processor = "stored_sig";
+ chain = "stored_sig";
addDoc(adoc("id", "2a", "v_t", "Hello Dude man!", "name", "ali babi'"));
addDoc(adoc("id", "2b", "v_t", "Hello Dude man!", "name", "ali babi'"));
addDoc(commit());
@@ -232,7 +232,7 @@ public class SignatureUpdateProcessorFac
private void addDoc(String doc) throws Exception {
Map<String, String[]> params = new HashMap<String, String[]>();
MultiMapSolrParams mmparams = new MultiMapSolrParams(params);
- params.put(UpdateParams.UPDATE_PROCESSOR, new String[] { processor });
+ params.put(UpdateParams.UPDATE_CHAIN, new String[] { chain });
SolrQueryRequestBase req = new SolrQueryRequestBase(h.getCore(),
(SolrParams) mmparams) {
};
Modified: lucene/dev/branches/realtime_search/solr/src/webapp/web/admin/analysis.jsp
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/webapp/web/admin/analysis.jsp?rev=1096120&r1=1096119&r2=1096120&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/webapp/web/admin/analysis.jsp (original)
+++ lucene/dev/branches/realtime_search/solr/src/webapp/web/admin/analysis.jsp Sat Apr 23 08:07:28 2011
@@ -222,6 +222,7 @@
public boolean incrementToken() throws IOException {
if (iter.hasNext()) {
+ clearAttributes();
AttributeSource token = iter.next();
Iterator<Class<? extends Attribute>> atts = token.getAttributeClassesIterator();
while (atts.hasNext()) // make sure all att impls in the token exist here
Modified: lucene/dev/branches/realtime_search/solr/src/webapp/web/admin/form.jsp
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/webapp/web/admin/form.jsp?rev=1096120&r1=1096119&r2=1096120&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/webapp/web/admin/form.jsp (original)
+++ lucene/dev/branches/realtime_search/solr/src/webapp/web/admin/form.jsp Sat Apr 23 08:07:28 2011
@@ -80,7 +80,7 @@
<strong>Output Type</strong>
</td>
<td>
- <input name="wt" type="text" value="standard">
+ <input name="wt" type="text" value="">
</td>
</tr>
<tr>