Uploaded image for project: 'Spring Data for Apache Solr'
  1. Spring Data for Apache Solr
  2. DATASOLR-325

SolrTemplate.getById() should not infer core name from entity class

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.1 M1 (Ingalls)
    • Fix Version/s: None
    • Component/s: Core
    • Labels:
      None

      Description

      The SolrTemplate.getById() method will infer the core name from @SolrDocument annotation and apply it when query for entity.

      return execute(new SolrCallback<Collection<T>>() {
      			@Override
      			public Collection<T> doInSolr(SolrClient solrClient) throws SolrServerException, IOException {
      
      				QueryResponse response = new SolrRealtimeGetRequest(ids).process(solrClient,
                                  getSolrCoreOrBeanCollection(clazz));
      				return convertSolrDocumentListToBeans(response.getResults(), clazz);
      			}
      
      		});
      

      But the other methods in SolrTemplate not do so, which can be confusing and lead to problematic query URL when you have specified the core name before.

      @Autowired @Qualified("fooCore")
      private SolrTemplate mSolrTemplate;
      
      public void testBar() {
          mSolrTemplate.getById(1, Foo.class);    // Exception if core name has been specified in SolrTemplate
          Query query = new SimpleQuery("*:*");
          mSolrTemplate.queryForPage(query, Foo.class);   // Exception if core name has not been specified in SolrTemplate
      }
      

        Attachments

          Activity

            People

            Assignee:
            cstrobl Christoph Strobl
            Reporter:
            AleiHanami Alei
            Last updater:
            Alei
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: