Colin Bartolome created SOLR-4389:
-------------------------------------

             Summary: CloudSolrServer serves all MoreLikeThis queries from the 
same collection
                 Key: SOLR-4389
                 URL: https://issues.apache.org/jira/browse/SOLR-4389
             Project: Solr
          Issue Type: Bug
          Components: clients - java
    Affects Versions: 4.0
            Reporter: Colin Bartolome


When using a CloudSolrServer instance to server MoreLikeThis queries, using the 
workaround mentioned in SOLR-1085, the server serves all queries using the 
collection specified by the first query, instead of using the one specified by 
the current query.

Example code:

import java.net.MalformedURLException;

import org.apache.solr.client.solrj.*;
import org.apache.solr.client.solrj.impl.CloudSolrServer;
import org.apache.solr.client.solrj.request.QueryRequest;
import org.apache.solr.common.params.*;

public class MoreLikeThisTest
{
   public static void main(String[] args)
      throws MalformedURLException, SolrServerException
   {
      CloudSolrServer server = new CloudSolrServer("zookeeper1:2181");
      
      server.connect();
      
      doMoreLikeThisQuery(server, "collection1");
      doMoreLikeThisQuery(server, "collection2");
   }
   
   private static void doMoreLikeThisQuery(SolrServer server, String collection)
         throws SolrServerException
   {
      SolrQuery solrQuery = new SolrQuery();
      
      solrQuery.set(CoreAdminParams.COLLECTION, collection);
      solrQuery.setRequestHandler("/" + MoreLikeThisParams.MLT);
      solrQuery.set(MoreLikeThisParams.SIMILARITY_FIELDS, "title");
      solrQuery.setQuery("id:1234");
      
      QueryRequest queryRequest = new QueryRequest(solrQuery, 
SolrRequest.METHOD.POST);
      
      queryRequest.process(server);
   }
}

Running this code results in two of my servers serving these requests:

INFO: [collection1] webapp=/solr path=/mlt 
params={fl=id&mlt.fl=title&q=id:1234&collection=collection1&qt=/mlt&wt=javabin&version=2}
 status=0 QTime=0 
INFO: [collection1] webapp=/solr path=/mlt 
params={fl=id&mlt.fl=title&q=id:1234&collection=collection2&qt=/mlt&wt=javabin&version=2}
 status=0 QTime=1 

The first collection serves both requests, meaning the second request will just 
about always return no results.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to