Spring Data Solr

org.springframework.data.solr.core
Class SolrTemplate

java.lang.Object
  extended by org.springframework.data.solr.core.SolrTemplate
All Implemented Interfaces:
Aware, InitializingBean, ApplicationContextAware, SolrOperations

public class SolrTemplate
extends Object
implements SolrOperations, InitializingBean, ApplicationContextAware

Implementation of SolrOperations

Author:
Christoph Strobl, Joachim Uhrlass, Francisco Spaeth

Constructor Summary
SolrTemplate(org.apache.solr.client.solrj.SolrServer solrServer)
           
SolrTemplate(SolrServerFactory solrServerFactory)
           
SolrTemplate(SolrServerFactory solrServerFactory, SolrConverter solrConverter)
           
SolrTemplate(org.apache.solr.client.solrj.SolrServer solrServer, String core)
           
 
Method Summary
 void afterPropertiesSet()
           
protected  void assertNoCollection(Object o)
           
 void commit()
          Send commit command SolrServer.commit()
 org.apache.solr.common.SolrInputDocument convertBeanToSolrInputDocument(Object bean)
          Convert given bean into a solrj InputDocument
<T> List<T>
convertQueryResponseToBeans(org.apache.solr.client.solrj.response.QueryResponse response, Class<T> targetClass)
           
<T> List<T>
convertSolrDocumentListToBeans(org.apache.solr.common.SolrDocumentList documents, Class<T> targetClass)
           
<T> T
convertSolrDocumentToBean(org.apache.solr.common.SolrDocument document, Class<T> targetClass)
           
 long count(SolrDataQuery query)
          return number of elements found by for given query
 org.apache.solr.client.solrj.response.UpdateResponse delete(SolrDataQuery query)
          Find and delete all objects matching the provided Query
 org.apache.solr.client.solrj.response.UpdateResponse deleteById(Collection<String> ids)
          Delete objects with given ids
 org.apache.solr.client.solrj.response.UpdateResponse deleteById(String id)
          Detele the one object with provided id
<T> T
execute(SolrCallback<T> action)
          Execute action within callback
 SolrConverter getConverter()
           
static PersistenceExceptionTranslator getExceptionTranslator()
           
 String getSolrCore()
           
 org.apache.solr.client.solrj.SolrServer getSolrServer()
          Get the underlying SolrServer instance
 org.apache.solr.client.solrj.response.SolrPingResponse ping()
          Execute ping against solrServer and return duration in msec
<T> FacetPage<T>
queryForFacetPage(FacetQuery query, Class<T> clazz)
          Execute a facet query against solr facet result will be returned along with query result within the FacetPage
<T> HighlightPage<T>
queryForHighlightPage(HighlightQuery query, Class<T> clazz)
          Execute a query and highlight matches in result
<T> T
queryForObject(Query query, Class<T> clazz)
          Execute the query against solr and return the first returned object
<T> Page<T>
queryForPage(Query query, Class<T> clazz)
          Execute the query against solr and retrun result as Page
 TermsPage queryForTermsPage(TermsQuery query)
          Execute query using terms handler
 void registerQueryParser(Class<? extends SolrDataQuery> clazz, QueryParser queryParser)
           
 void rollback()
          send rollback command SolrServer.rollback()
 org.apache.solr.client.solrj.response.UpdateResponse saveBean(Object obj)
          Execute add operation against solr, which will do either insert or update
 org.apache.solr.client.solrj.response.UpdateResponse saveBean(Object objectToAdd, int commitWithinMs)
          Execute add operation against solr, which will do either insert or update with support for commitWithin strategy
 org.apache.solr.client.solrj.response.UpdateResponse saveBeans(Collection<?> beans)
          Add a collection of beans to solr, which will do either insert or update
 org.apache.solr.client.solrj.response.UpdateResponse saveBeans(Collection<?> beansToAdd, int commitWithinMs)
          Add a collection of beans to solr, which will do either insert or update with support for commitWithin strategy
 org.apache.solr.client.solrj.response.UpdateResponse saveDocument(org.apache.solr.common.SolrInputDocument document)
          Add a solrj input document to solr, which will do either insert or update
 org.apache.solr.client.solrj.response.UpdateResponse saveDocument(org.apache.solr.common.SolrInputDocument documentToAdd, int commitWithinMs)
          Add a solrj input document to solr, which will do either insert or update with support for commitWithin strategy
 org.apache.solr.client.solrj.response.UpdateResponse saveDocuments(Collection<org.apache.solr.common.SolrInputDocument> documents)
          Add multiple solrj input documents to solr, which will do either insert or update
 org.apache.solr.client.solrj.response.UpdateResponse saveDocuments(Collection<org.apache.solr.common.SolrInputDocument> documentsToAdd, int commitWithinMs)
          Add multiple solrj input documents to solr, which will do either insert or update with support for commitWithin strategy
 void setApplicationContext(ApplicationContext applicationContext)
           
 void setSolrConverter(SolrConverter solrConverter)
           
 void setSolrCore(String solrCore)
           
 void softCommit()
          Send soft commmit command SolrServer.commit(boolean, boolean, boolean)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SolrTemplate

public SolrTemplate(org.apache.solr.client.solrj.SolrServer solrServer)

SolrTemplate

public SolrTemplate(org.apache.solr.client.solrj.SolrServer solrServer,
                    String core)

SolrTemplate

public SolrTemplate(SolrServerFactory solrServerFactory)

SolrTemplate

public SolrTemplate(SolrServerFactory solrServerFactory,
                    SolrConverter solrConverter)
Method Detail

execute

public <T> T execute(SolrCallback<T> action)
Description copied from interface: SolrOperations
Execute action within callback

Specified by:
execute in interface SolrOperations
Returns:

ping

public org.apache.solr.client.solrj.response.SolrPingResponse ping()
Description copied from interface: SolrOperations
Execute ping against solrServer and return duration in msec

Specified by:
ping in interface SolrOperations
Returns:

count

public long count(SolrDataQuery query)
Description copied from interface: SolrOperations
return number of elements found by for given query

Specified by:
count in interface SolrOperations
Returns:

saveBean

public org.apache.solr.client.solrj.response.UpdateResponse saveBean(Object obj)
Description copied from interface: SolrOperations
Execute add operation against solr, which will do either insert or update

Specified by:
saveBean in interface SolrOperations
Returns:

saveBean

public org.apache.solr.client.solrj.response.UpdateResponse saveBean(Object objectToAdd,
                                                                     int commitWithinMs)
Description copied from interface: SolrOperations
Execute add operation against solr, which will do either insert or update with support for commitWithin strategy

Specified by:
saveBean in interface SolrOperations
Returns:

saveBeans

public org.apache.solr.client.solrj.response.UpdateResponse saveBeans(Collection<?> beans)
Description copied from interface: SolrOperations
Add a collection of beans to solr, which will do either insert or update

Specified by:
saveBeans in interface SolrOperations
Returns:

saveBeans

public org.apache.solr.client.solrj.response.UpdateResponse saveBeans(Collection<?> beansToAdd,
                                                                      int commitWithinMs)
Description copied from interface: SolrOperations
Add a collection of beans to solr, which will do either insert or update with support for commitWithin strategy

Specified by:
saveBeans in interface SolrOperations
Returns:

saveDocument

public org.apache.solr.client.solrj.response.UpdateResponse saveDocument(org.apache.solr.common.SolrInputDocument document)
Description copied from interface: SolrOperations
Add a solrj input document to solr, which will do either insert or update

Specified by:
saveDocument in interface SolrOperations
Returns:

saveDocument

public org.apache.solr.client.solrj.response.UpdateResponse saveDocument(org.apache.solr.common.SolrInputDocument documentToAdd,
                                                                         int commitWithinMs)
Description copied from interface: SolrOperations
Add a solrj input document to solr, which will do either insert or update with support for commitWithin strategy

Specified by:
saveDocument in interface SolrOperations
Returns:

saveDocuments

public org.apache.solr.client.solrj.response.UpdateResponse saveDocuments(Collection<org.apache.solr.common.SolrInputDocument> documents)
Description copied from interface: SolrOperations
Add multiple solrj input documents to solr, which will do either insert or update

Specified by:
saveDocuments in interface SolrOperations
Returns:

saveDocuments

public org.apache.solr.client.solrj.response.UpdateResponse saveDocuments(Collection<org.apache.solr.common.SolrInputDocument> documentsToAdd,
                                                                          int commitWithinMs)
Description copied from interface: SolrOperations
Add multiple solrj input documents to solr, which will do either insert or update with support for commitWithin strategy

Specified by:
saveDocuments in interface SolrOperations
Returns:

delete

public org.apache.solr.client.solrj.response.UpdateResponse delete(SolrDataQuery query)
Description copied from interface: SolrOperations
Find and delete all objects matching the provided Query

Specified by:
delete in interface SolrOperations
Returns:

deleteById

public org.apache.solr.client.solrj.response.UpdateResponse deleteById(String id)
Description copied from interface: SolrOperations
Detele the one object with provided id

Specified by:
deleteById in interface SolrOperations
Returns:

deleteById

public org.apache.solr.client.solrj.response.UpdateResponse deleteById(Collection<String> ids)
Description copied from interface: SolrOperations
Delete objects with given ids

Specified by:
deleteById in interface SolrOperations
Returns:

queryForObject

public <T> T queryForObject(Query query,
                            Class<T> clazz)
Description copied from interface: SolrOperations
Execute the query against solr and return the first returned object

Specified by:
queryForObject in interface SolrOperations
Returns:
the first matching object

queryForPage

public <T> Page<T> queryForPage(Query query,
                                Class<T> clazz)
Description copied from interface: SolrOperations
Execute the query against solr and retrun result as Page

Specified by:
queryForPage in interface SolrOperations
Returns:

queryForFacetPage

public <T> FacetPage<T> queryForFacetPage(FacetQuery query,
                                          Class<T> clazz)
Description copied from interface: SolrOperations
Execute a facet query against solr facet result will be returned along with query result within the FacetPage

Specified by:
queryForFacetPage in interface SolrOperations
Returns:

queryForHighlightPage

public <T> HighlightPage<T> queryForHighlightPage(HighlightQuery query,
                                                  Class<T> clazz)
Description copied from interface: SolrOperations
Execute a query and highlight matches in result

Specified by:
queryForHighlightPage in interface SolrOperations
Returns:

queryForTermsPage

public TermsPage queryForTermsPage(TermsQuery query)
Description copied from interface: SolrOperations
Execute query using terms handler

Specified by:
queryForTermsPage in interface SolrOperations
Returns:

commit

public void commit()
Description copied from interface: SolrOperations
Send commit command SolrServer.commit()

Specified by:
commit in interface SolrOperations

softCommit

public void softCommit()
Description copied from interface: SolrOperations
Send soft commmit command SolrServer.commit(boolean, boolean, boolean)

Specified by:
softCommit in interface SolrOperations

rollback

public void rollback()
Description copied from interface: SolrOperations
send rollback command SolrServer.rollback()

Specified by:
rollback in interface SolrOperations

convertBeanToSolrInputDocument

public org.apache.solr.common.SolrInputDocument convertBeanToSolrInputDocument(Object bean)
Description copied from interface: SolrOperations
Convert given bean into a solrj InputDocument

Specified by:
convertBeanToSolrInputDocument in interface SolrOperations
Returns:

convertQueryResponseToBeans

public <T> List<T> convertQueryResponseToBeans(org.apache.solr.client.solrj.response.QueryResponse response,
                                               Class<T> targetClass)

convertSolrDocumentListToBeans

public <T> List<T> convertSolrDocumentListToBeans(org.apache.solr.common.SolrDocumentList documents,
                                                  Class<T> targetClass)

convertSolrDocumentToBean

public <T> T convertSolrDocumentToBean(org.apache.solr.common.SolrDocument document,
                                       Class<T> targetClass)

assertNoCollection

protected void assertNoCollection(Object o)

getSolrServer

public final org.apache.solr.client.solrj.SolrServer getSolrServer()
Description copied from interface: SolrOperations
Get the underlying SolrServer instance

Specified by:
getSolrServer in interface SolrOperations
Returns:

getConverter

public SolrConverter getConverter()
Specified by:
getConverter in interface SolrOperations
Returns:
Converter in use

getExceptionTranslator

public static PersistenceExceptionTranslator getExceptionTranslator()

setApplicationContext

public void setApplicationContext(ApplicationContext applicationContext)
Specified by:
setApplicationContext in interface ApplicationContextAware

registerQueryParser

public void registerQueryParser(Class<? extends SolrDataQuery> clazz,
                                QueryParser queryParser)

setSolrConverter

public void setSolrConverter(SolrConverter solrConverter)

getSolrCore

public String getSolrCore()

setSolrCore

public void setSolrCore(String solrCore)

afterPropertiesSet

public void afterPropertiesSet()
Specified by:
afterPropertiesSet in interface InitializingBean

Spring Data Solr

Copyright © 2011-2014-2014 Pivotal. All Rights Reserved.