Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-4389

CloudSolrServer serves all MoreLikeThis queries from the same collection

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 4.0
    • None
    • clients - java
    • None

    Description

      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.

      Attachments

        Activity

          People

            markrmiller@gmail.com Mark Miller
            cbartolo Colin Bartolome
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: