You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by er...@apache.org on 2014/08/18 21:45:18 UTC
svn commit: r1618716 - in /lucene/dev/trunk/solr: CHANGES.txt
core/src/java/org/apache/solr/handler/component/FacetComponent.java
core/src/test/org/apache/solr/TestDistributedSearch.java
core/src/test/org/apache/solr/request/TestFaceting.java
Author: erick
Date: Mon Aug 18 19:45:17 2014
New Revision: 1618716
URL: http://svn.apache.org/r1618716
Log:
SOLR-6314: Multi-threaded facet counts differ when SolrCloud has >1 shard
Modified:
lucene/dev/trunk/solr/CHANGES.txt
lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/component/FacetComponent.java
lucene/dev/trunk/solr/core/src/test/org/apache/solr/TestDistributedSearch.java
lucene/dev/trunk/solr/core/src/test/org/apache/solr/request/TestFaceting.java
Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1618716&r1=1618715&r2=1618716&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Mon Aug 18 19:45:17 2014
@@ -292,6 +292,8 @@ Bug Fixes
* SOLR-6338: coreRootDirectory requires trailing slash, or SolrCloud cores are created in wrong location.
(Primož Skale via Erick Erickson)
+* SOLR-6314: Multi-threaded facet counts differ when SolrCloud has >1 shard (Erick Erickson)
+
Optimizations
---------------------
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/component/FacetComponent.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/component/FacetComponent.java?rev=1618716&r1=1618715&r2=1618716&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/component/FacetComponent.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/component/FacetComponent.java Mon Aug 18 19:45:17 2014
@@ -24,10 +24,11 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
import java.util.List;
-import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
@@ -84,8 +85,22 @@ public class FacetComponent extends Sear
*/
@Override
public void process(ResponseBuilder rb) throws IOException {
+
+ //SolrParams params = rb.req.getParams();
if (rb.doFacets) {
- SolrParams params = rb.req.getParams();
+ ModifiableSolrParams params = new ModifiableSolrParams();
+ SolrParams origParams = rb.req.getParams();
+ Iterator<String> iter = origParams.getParameterNamesIterator();
+ while (iter.hasNext()) {
+ String paramName = iter.next();
+ // Deduplicate the list with LinkedHashSet, but _only_ for facet params.
+ if (paramName.startsWith(FacetParams.FACET) == false) {
+ params.add(paramName, origParams.getParams(paramName));
+ continue;
+ }
+ HashSet<String> deDupe = new LinkedHashSet<>(Arrays.asList(origParams.getParams(paramName)));
+ params.add(paramName, deDupe.toArray(new String[deDupe.size()]));
+ }
SimpleFacets f = new SimpleFacets(rb.req, rb.getResults().docSet, params, rb);
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/TestDistributedSearch.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/TestDistributedSearch.java?rev=1618716&r1=1618715&r2=1618716&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/TestDistributedSearch.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/TestDistributedSearch.java Mon Aug 18 19:45:17 2014
@@ -168,9 +168,9 @@ 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",0, "facet","true", "facet.field",t1);
+ query("q","*:*", "rows",0, "facet","true", "facet.field",t1, "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.query","quick", "facet.query","quick", "facet.query","all", "facet.query","*:*");
query("q","*:*", "rows",0, "facet","true", "facet.field",t1, "facet.mincount",2);
// a facet query to test out chars out of the ascii range
@@ -188,7 +188,8 @@ public class TestDistributedSearch exten
// simple date facet on one field
query("q","*:*", "rows",100, "facet","true",
- "facet.date",tdate_a,
+ "facet.date",tdate_a,
+ "facet.date",tdate_a,
"facet.date.other", "all",
"facet.date.start","2010-05-01T11:00:00Z",
"facet.date.gap","+1DAY",
@@ -196,8 +197,9 @@ public class TestDistributedSearch exten
// date facet on multiple fields
query("q","*:*", "rows",100, "facet","true",
- "facet.date",tdate_a,
- "facet.date",tdate_b,
+ "facet.date",tdate_a,
+ "facet.date",tdate_b,
+ "facet.date",tdate_a,
"facet.date.other", "all",
"f."+tdate_b+".facet.date.start","2009-05-01T11:00:00Z",
"f."+tdate_b+".facet.date.gap","+3MONTHS",
@@ -207,7 +209,8 @@ public class TestDistributedSearch exten
// simple range facet on one field
query("q","*:*", "rows",100, "facet","true",
- "facet.range",tlong,
+ "facet.range",tlong,
+ "facet.range",tlong,
"facet.range.start",200,
"facet.range.gap",100,
"facet.range.end",900);
@@ -378,6 +381,7 @@ public class TestDistributedSearch exten
"q","*:*",
"facet","true",
"facet.field",t1,
+ "facet.field",t1,
"facet.limit",5,
ShardParams.SHARDS_INFO,"true",
ShardParams.SHARDS_TOLERANT,"true");
@@ -386,6 +390,7 @@ public class TestDistributedSearch exten
"q", "*:*",
"facet", "true",
"facet.query", i1 + ":[1 TO 50]",
+ "facet.query", i1 + ":[1 TO 50]",
ShardParams.SHARDS_INFO, "true",
ShardParams.SHARDS_TOLERANT, "true");
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/request/TestFaceting.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/request/TestFaceting.java?rev=1618716&r1=1618715&r2=1618716&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/request/TestFaceting.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/request/TestFaceting.java Mon Aug 18 19:45:17 2014
@@ -713,8 +713,8 @@ public class TestFaceting extends SolrTe
, "facet.threads", "1000"
, "facet.limit", "-1"
)
- , "*[count(//lst[@name='facet_fields']/lst)=50]"
- , "*[count(//lst[@name='facet_fields']/lst/int)=100]"
+ , "*[count(//lst[@name='facet_fields']/lst)=10]"
+ , "*[count(//lst[@name='facet_fields']/lst/int)=20]"
);
}
@@ -859,8 +859,7 @@ public class TestFaceting extends SolrTe
);
// After this all, the uninverted fields should be exactly the same as they were the first time, even if we
- // blast a whole bunch of identical fields at the facet code. Which, BTW, doesn't detect
- // if you've asked for the same field more than once.
+ // blast a whole bunch of identical fields at the facet code.
// The way fetching the uninverted field is written, all this is really testing is if the cache is working.
// It's NOT testing whether the pending/sleep is actually functioning, I had to do that by hand since I don't
// see how to make sure that uninverting the field multiple times actually happens to hit the wait state.
@@ -920,8 +919,8 @@ public class TestFaceting extends SolrTe
, "facet.threads", "1000"
, "facet.limit", "-1"
)
- , "*[count(//lst[@name='facet_fields']/lst)=50]"
- , "*[count(//lst[@name='facet_fields']/lst/int)=100]"
+ , "*[count(//lst[@name='facet_fields']/lst)=10]"
+ , "*[count(//lst[@name='facet_fields']/lst/int)=20]"
);
} finally {
currentSearcherRef.decref();