Skip to content

Apache Lucene open-source search software

SOLR-788: set mlt.count back to 5

Mark Robert Miller5feeb36d4689
diff --git a/solr/core/src/java/org/apache/solr/handler/component/MoreLikeThisComponent.java b/solr/core/src/java/org/apache/solr/handler/component/MoreLikeThisComponent.java
index b96ce4c5e1d..6ee73746f32 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/MoreLikeThisComponent.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/MoreLikeThisComponent.java
@@ -75,7 +75,7 @@ public class MoreLikeThisComponent extends SearchComponent {
+ params.getBool(ShardParams.IS_SHARD));
SolrIndexSearcher searcher = rb.req.getSearcher();
- int mltcount = params.getInt(MoreLikeThisParams.DOC_COUNT, 20);
+ int mltcount = params.getInt(MoreLikeThisParams.DOC_COUNT, 5);
if (params.getBool(ShardParams.IS_SHARD, false)) {
if (params.get(MoreLikeThisComponent.DIST_DOC_ID) == null) {
if (rb.getResults().docList.size() == 0) {
@@ -156,7 +156,7 @@ public class MoreLikeThisComponent extends SearchComponent {
&& rb.req.getParams().getBool(COMPONENT_NAME, false)) {
Map<Object,SolrDocumentList> tempResults = new LinkedHashMap<Object,SolrDocumentList>();
- int mltcount = rb.req.getParams().getInt(MoreLikeThisParams.DOC_COUNT, 20);
+ int mltcount = rb.req.getParams().getInt(MoreLikeThisParams.DOC_COUNT, 5);
String keyName = rb.req.getSchema().getUniqueKeyField().getName();
for (ShardRequest sreq : rb.finished) {
@@ -298,7 +298,7 @@ public class MoreLikeThisComponent extends SearchComponent {
// needed to correlate results
s.params.set(MoreLikeThisComponent.DIST_DOC_ID, key);
s.params.set(CommonParams.START, 0);
- int mltcount = s.params.getInt(MoreLikeThisParams.DOC_COUNT, 20);
+ int mltcount = s.params.getInt(MoreLikeThisParams.DOC_COUNT, 20); // overrequest
s.params.set(CommonParams.ROWS, mltcount);
// adding score to rank moreLikeThis
@@ -352,7 +352,7 @@ public class MoreLikeThisComponent extends SearchComponent {
while (iterator.hasNext()) {
int id = iterator.nextDoc();
- int rows = p.getInt(MoreLikeThisParams.DOC_COUNT, 20);
+ int rows = p.getInt(MoreLikeThisParams.DOC_COUNT, 5);
DocListAndSet sim = mltHelper.getMoreLikeThis(id, 0, rows, null, null,
flags);
String name = schema.printableUniqueKey(searcher.doc(id));
diff --git a/solr/core/src/test/org/apache/solr/handler/component/DistributedMLTComponentTest.java b/solr/core/src/test/org/apache/solr/handler/component/DistributedMLTComponentTest.java
index 06eece6db3c..c9bae31366d 100644
--- a/solr/core/src/test/org/apache/solr/handler/component/DistributedMLTComponentTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/component/DistributedMLTComponentTest.java
@@ -31,7 +31,7 @@ import org.junit.Ignore;
* @see org.apache.solr.handler.component.MoreLikeThisComponent
*/
@Slow
-@Ignore("distrib mlt not working right")
+@Ignore("fails on freebsd")
public class DistributedMLTComponentTest extends BaseDistributedSearchTestCase {
private String requestHandlerName;
@@ -122,24 +122,27 @@ public class DistributedMLTComponentTest extends BaseDistributedSearchTestCase {
// per shard - because of this, depending on params, distrib and single
// shard queries will not match.
+ // because distrib and single node do not currently sort exactly the same,
+ // we ask for an mlt.count of 20 to ensure both include all results
+
query("q", "lowerfilt:moon", "fl", id, MoreLikeThisParams.MIN_TERM_FREQ, 2,
MoreLikeThisParams.MIN_DOC_FREQ, 1, "sort", "id desc", "mlt", "true",
"mlt.fl", "lowerfilt", "qt", requestHandlerName, "shards.qt",
- requestHandlerName);
+ requestHandlerName, "mlt.count", "20");
query("q", "lowerfilt:fox", "fl", id, MoreLikeThisParams.MIN_TERM_FREQ, 1,
MoreLikeThisParams.MIN_DOC_FREQ, 1, "sort", "id desc", "mlt", "true",
"mlt.fl", "lowerfilt", "qt", requestHandlerName, "shards.qt",
- requestHandlerName);
+ requestHandlerName, "mlt.count", "20");
query("q", "lowerfilt:the red fox", "fl", id, MoreLikeThisParams.MIN_TERM_FREQ, 1,
MoreLikeThisParams.MIN_DOC_FREQ, 1, "sort", "id desc", "mlt", "true",
"mlt.fl", "lowerfilt", "qt", requestHandlerName, "shards.qt",
- requestHandlerName);
+ requestHandlerName, "mlt.count", "20");
query("q", "lowerfilt:blue moon", "fl", id, MoreLikeThisParams.MIN_TERM_FREQ, 1,
MoreLikeThisParams.MIN_DOC_FREQ, 1, "sort", "id desc", "mlt", "true",
"mlt.fl", "lowerfilt", "qt", requestHandlerName, "shards.qt",
- requestHandlerName);
+ requestHandlerName, "mlt.count", "20");
}
}