Interface SolrOperations
- All Known Implementing Classes:
SolrTemplate
public interface SolrOperations
Interface that specifies a basic set of Solr operations.
-
Method Summary
Modifier and TypeMethodDescriptionvoidSend commit commandSolrClient.commit()org.apache.solr.common.SolrInputDocumentConvert given bean into a solrj InputDocumentdefault longcount(String collection, SolrDataQuery query) return number of elements found by for given querylongcount(String collection, SolrDataQuery query, Class<?> domainType) return number of elements found by for given querylongcount(String collection, SolrDataQuery query, Class<?> domainType, RequestMethod method) return number of elements found by for given querydefault longcount(String collection, SolrDataQuery query, RequestMethod method) return number of elements found by for given querydefault org.apache.solr.client.solrj.response.UpdateResponsedelete(String collection, SolrDataQuery query) Find and delete all objects matching the provided Query.org.apache.solr.client.solrj.response.UpdateResponsedelete(String collection, SolrDataQuery query, Class<?> domainType) Find and delete all objects matching the provided Query.org.apache.solr.client.solrj.response.UpdateResponsedeleteByIds(String collection, String id) Detele the one object with provided id.org.apache.solr.client.solrj.response.UpdateResponsedeleteByIds(String collection, Collection<String> id) Delete objects with given ids<T> Texecute(SolrCallback<T> action) Execute action within callback<T> Optional<T>Executes a realtime get using given id.<T> Collection<T>getByIds(String collection, Collection<?> ids, Class<T> clazz) Executes a realtime get using given ids.getSchemaOperations(String collection) Get theSchemaOperationsexecutable.org.apache.solr.client.solrj.SolrClientGet the underlying SolrClient instanceorg.apache.solr.client.solrj.response.SolrPingResponseping()Execute ping against SolrClient and return duration in msecorg.apache.solr.client.solrj.response.SolrPingResponseExecute ping against SolrClient and return duration in msec<T,S extends org.springframework.data.domain.Page<T>>
SExecute the query against Solr and return result as page.<T,S extends org.springframework.data.domain.Page<T>>
Squery(String collection, Query query, Class<T> clazz, RequestMethod method) Execute the query against Solr and return result as page.<T> Cursor<T>queryForCursor(String collection, Query query, Class<T> clazz) <T> FacetAndHighlightPage<T>queryForFacetAndHighlightPage(String collection, FacetAndHighlightQuery query, Class<T> clazz) Execute a query and highlight matches in result<T> FacetAndHighlightPage<T>queryForFacetAndHighlightPage(String collection, FacetAndHighlightQuery query, Class<T> clazz, RequestMethod method) Execute a query and highlight matches in result<T> FacetPage<T>queryForFacetPage(String collection, FacetQuery query, Class<T> clazz) Execute a facet query against solr facet result will be returned along with query result within the FacetPage<T> FacetPage<T>queryForFacetPage(String collection, FacetQuery query, Class<T> clazz, RequestMethod method) Execute a facet query against solr facet result will be returned along with query result within the FacetPage<T> GroupPage<T>queryForGroupPage(String collection, Query query, Class<T> clazz) Execute the query against solr and return result asGroupPage<T> GroupPage<T>queryForGroupPage(String collection, Query query, Class<T> clazz, RequestMethod method) Execute the query against solr and return result asGroupPage<T> HighlightPage<T>queryForHighlightPage(String collection, HighlightQuery query, Class<T> clazz) Execute a query and highlight matches in result<T> HighlightPage<T>queryForHighlightPage(String collection, HighlightQuery query, Class<T> clazz, RequestMethod method) Execute a query and highlight matches in result<T> Optional<T>queryForObject(String collection, Query query, Class<T> clazz) Execute the query against solr and return the first returned object<T> Optional<T>queryForObject(String collection, Query query, Class<T> clazz, RequestMethod method) Execute the query against solr and return the first returned object<T> ScoredPage<T>queryForPage(String collection, Query query, Class<T> clazz) Execute the query against solr and retrun result asPage<T> ScoredPage<T>queryForPage(String collection, Query query, Class<T> clazz, RequestMethod method) Execute the query against solr and retrun result asPage<T> StatsPage<T>queryForStatsPage(String collection, Query query, Class<T> clazz) Execute the query against Solr and return result asStatsPage.<T> StatsPage<T>queryForStatsPage(String collection, Query query, Class<T> clazz, RequestMethod method) Execute the query against Solr and return result asStatsPage.queryForTermsPage(String collection, TermsQuery query) Execute query using terms handlerqueryForTermsPage(String collection, TermsQuery query, RequestMethod method) Execute query using terms handlervoidsend rollback commandSolrClient.rollback()default org.apache.solr.client.solrj.response.UpdateResponseExecute add operation against solr, which will do either insert or update.org.apache.solr.client.solrj.response.UpdateResponseExecute add operation against solr, which will do either insert or update with support for commitWithin strategy.default org.apache.solr.client.solrj.response.UpdateResponsesaveBeans(String collection, Collection<?> beans) Add a collection of beans to solr, which will do either insert or update.org.apache.solr.client.solrj.response.UpdateResponsesaveBeans(String collection, Collection<?> beans, Duration commitWithin) Add a collection of beans to solr, which will do either insert or update with support for commitWithin strategy.default org.apache.solr.client.solrj.response.UpdateResponsesaveDocument(String collection, org.apache.solr.common.SolrInputDocument document) Add a solrj input document to solr, which will do either insert or updateorg.apache.solr.client.solrj.response.UpdateResponsesaveDocument(String collection, org.apache.solr.common.SolrInputDocument document, Duration commitWithin) Add a solrj input document to solr, which will do either insert or update with support for commitWithin strategydefault org.apache.solr.client.solrj.response.UpdateResponsesaveDocuments(String collection, Collection<org.apache.solr.common.SolrInputDocument> documents) Add multiple solrj input documents to solr, which will do either insert or updateorg.apache.solr.client.solrj.response.UpdateResponsesaveDocuments(String collection, Collection<org.apache.solr.common.SolrInputDocument> documents, Duration commitWithin) Add multiple solrj input documents to solr, which will do either insert or update with support for commitWithin strategy.voidsoftCommit(String collection) Send soft commmit commandSolrClient.commit(boolean, boolean, boolean)
-
Method Details
-
getSolrClient
org.apache.solr.client.solrj.SolrClient getSolrClient()Get the underlying SolrClient instance- Returns:
- the
SolrClientin use. Never null.
-
ping
org.apache.solr.client.solrj.response.SolrPingResponse ping()Execute ping against SolrClient and return duration in msec- Returns:
SolrPingResponsecontaining ping result.- Throws:
org.springframework.dao.DataAccessResourceFailureException- if ping fails.
-
ping
Execute ping against SolrClient and return duration in msec- Parameters:
collection- must not be null.- Returns:
SolrPingResponsecontaining ping result.- Throws:
org.springframework.dao.DataAccessResourceFailureException- if ping fails.- Since:
- 3.0
-
count
return number of elements found by for given query- Parameters:
collection- must not be null.query- must not be null.- Returns:
- total number of documents matching given query.
- Since:
- 3.0
-
count
return number of elements found by for given query- Parameters:
collection- must not be null.query- must not be null.domainType- can be null.- Returns:
- total number of documents matching given query.
- Since:
- 4.0
-
count
long count(String collection, SolrDataQuery query, @Nullable Class<?> domainType, RequestMethod method) return number of elements found by for given query- Parameters:
collection- must not be null.query- must not be null.domainType- can be null.method- must not be null.- Returns:
- total number of documents matching given query.
- Since:
- 4.0
-
count
return number of elements found by for given query- Parameters:
collection- must not be null.query- must not be null.method- must not be null.- Returns:
- total number of documents matching given query.
- Since:
- 3.0
-
saveBean
default org.apache.solr.client.solrj.response.UpdateResponse saveBean(String collection, Object obj) Execute add operation against solr, which will do either insert or update.- Parameters:
collection- must not be null.obj- must not be null.- Returns:
UpdateResponsecontaining update result.- Since:
- 3.0
-
saveBean
org.apache.solr.client.solrj.response.UpdateResponse saveBean(String collection, Object obj, Duration commitWithin) Execute add operation against solr, which will do either insert or update with support for commitWithin strategy.- Parameters:
collection- must not be null.obj- must not be null.commitWithin- max time within server performs commit.- Returns:
UpdateResponsecontaining update result.
-
saveBeans
default org.apache.solr.client.solrj.response.UpdateResponse saveBeans(String collection, Collection<?> beans) Add a collection of beans to solr, which will do either insert or update.- Parameters:
collection- must not be null.beans- must not be null.- Returns:
UpdateResponsecontaining update result.- Since:
- 3.0
-
saveBeans
org.apache.solr.client.solrj.response.UpdateResponse saveBeans(String collection, Collection<?> beans, Duration commitWithin) Add a collection of beans to solr, which will do either insert or update with support for commitWithin strategy.- Parameters:
collection- must not be null.beans- must not be null.commitWithin- max time within server performs commit.- Returns:
UpdateResponsecontaining update result.- Since:
- 3.0
-
saveDocument
default org.apache.solr.client.solrj.response.UpdateResponse saveDocument(String collection, org.apache.solr.common.SolrInputDocument document) Add a solrj input document to solr, which will do either insert or update- Parameters:
collection- must not be null.document- must not be null.- Returns:
UpdateResponsecontaining update result.
-
saveDocument
org.apache.solr.client.solrj.response.UpdateResponse saveDocument(String collection, org.apache.solr.common.SolrInputDocument document, Duration commitWithin) Add a solrj input document to solr, which will do either insert or update with support for commitWithin strategy- Parameters:
document- must not be null.commitWithin- must not be null.- Returns:
UpdateResponsecontaining update result.- Since:
- 3.0
-
saveDocuments
default org.apache.solr.client.solrj.response.UpdateResponse saveDocuments(String collection, Collection<org.apache.solr.common.SolrInputDocument> documents) Add multiple solrj input documents to solr, which will do either insert or update- Parameters:
collection- must not be null.documents- must not be null.- Returns:
UpdateResponsecontaining update result.- Since:
- 3.0
-
saveDocuments
org.apache.solr.client.solrj.response.UpdateResponse saveDocuments(String collection, Collection<org.apache.solr.common.SolrInputDocument> documents, Duration commitWithin) Add multiple solrj input documents to solr, which will do either insert or update with support for commitWithin strategy.- Parameters:
collection- must not be null.documents- must not be null.commitWithin- max time within server performs commit.- Returns:
UpdateResponsecontaining update result.- Since:
- 3.0
-
delete
default org.apache.solr.client.solrj.response.UpdateResponse delete(String collection, SolrDataQuery query) Find and delete all objects matching the provided Query.- Parameters:
collection- must not be null.query- must not be null.- Returns:
UpdateResponsecontaining delete result.- Since:
- 3.0
-
delete
org.apache.solr.client.solrj.response.UpdateResponse delete(String collection, SolrDataQuery query, @Nullable Class<?> domainType) Find and delete all objects matching the provided Query.- Parameters:
collection- must not be null.query- must not be null.- Returns:
UpdateResponsecontaining delete result.- Since:
- 4.0
-
deleteByIds
Detele the one object with provided id.- Parameters:
collection- must not be null.id- must not be null.- Returns:
UpdateResponsecontaining delete result.- Since:
- 3.0
-
deleteByIds
org.apache.solr.client.solrj.response.UpdateResponse deleteByIds(String collection, Collection<String> id) Delete objects with given ids- Parameters:
collection- must not be null.id- must not be null.- Returns:
UpdateResponsecontaining delete result.- Since:
- 3.0
-
queryForObject
Execute the query against solr and return the first returned object- Parameters:
collection- must not be null.query- must not be null.clazz- must not be null.- Returns:
- the first matching object
- Since:
- 3.0
-
queryForObject
<T> Optional<T> queryForObject(String collection, Query query, Class<T> clazz, RequestMethod method) Execute the query against solr and return the first returned object- Parameters:
collection- must not be null.query- must not be null.clazz- must not be null.method- must not be null.- Returns:
- the first matching object
- Since:
- 3.0
-
queryForPage
Execute the query against solr and retrun result asPage- Parameters:
collection- must not be null.query- must not be null.clazz- must not be null.- Returns:
- never null.
- Since:
- 3.0
-
queryForPage
<T> ScoredPage<T> queryForPage(String collection, Query query, Class<T> clazz, RequestMethod method) Execute the query against solr and retrun result asPage- Parameters:
collection- must not be null.query- must not be null.clazz- must not be null.method- must not be null.- Returns:
- never null.
- Since:
- 3.0
-
queryForFacetPage
Execute a facet query against solr facet result will be returned along with query result within the FacetPage- Parameters:
collection- must not be null.query- must not be null.clazz- must not be null.- Returns:
- never null.
- Since:
- 3.0
-
queryForFacetPage
<T> FacetPage<T> queryForFacetPage(String collection, FacetQuery query, Class<T> clazz, RequestMethod method) Execute a facet query against solr facet result will be returned along with query result within the FacetPage- Parameters:
collection- must not be null.query- must not be null.clazz- must not be null.method- must not be null.- Returns:
- never null.
- Since:
- 3.0
-
queryForHighlightPage
Execute a query and highlight matches in result- Parameters:
collection- must not be null.query- must not be null.clazz- must not be null.- Returns:
- never null.
- Since:
- 3.0
-
queryForHighlightPage
<T> HighlightPage<T> queryForHighlightPage(String collection, HighlightQuery query, Class<T> clazz, RequestMethod method) Execute a query and highlight matches in result- Parameters:
collection- must not be null.query- must not be null.clazz- must not be null.method- must not be null.- Returns:
- never null.
- Since:
- 3.0
-
queryForFacetAndHighlightPage
<T> FacetAndHighlightPage<T> queryForFacetAndHighlightPage(String collection, FacetAndHighlightQuery query, Class<T> clazz) Execute a query and highlight matches in result- Parameters:
collection- must not be null.query- must not be null.clazz- must not be null.- Returns:
- never null.
- Since:
- 3.0
-
queryForFacetAndHighlightPage
<T> FacetAndHighlightPage<T> queryForFacetAndHighlightPage(String collection, FacetAndHighlightQuery query, Class<T> clazz, RequestMethod method) Execute a query and highlight matches in result- Parameters:
collection- must not be null.query- must not be null.clazz- must not be null.method- must not be null.- Returns:
- never null.
- Since:
- 3.0
-
queryForTermsPage
Execute query using terms handler- Parameters:
collection- must not be null.query- must not be null.- Returns:
- never null.
- Since:
- 3.0
-
queryForTermsPage
Execute query using terms handler- Parameters:
collection- must not be null.query- must not be null.method- must not be null.- Returns:
- never null.
- Since:
- 3.0
-
queryForCursor
Executes the givenQueryand returns an openCursorallowing to iterate of results, dynamically fetching additional ones if required.- Parameters:
collection- must not be null.query- must not be null.clazz- must not be null.- Returns:
- never null.
- Since:
- 3.0
-
queryForGroupPage
Execute the query against solr and return result asGroupPage- Parameters:
collection- must not be null.query- must not be null.clazz- must not be null.- Returns:
- never null.
- Since:
- 3.0
-
queryForGroupPage
<T> GroupPage<T> queryForGroupPage(String collection, Query query, Class<T> clazz, RequestMethod method) Execute the query against solr and return result asGroupPage- Parameters:
collection- must not be null.query- must not be null.clazz- must not be null.method- must not be null.- Returns:
- never null.
- Since:
- 3.0
-
queryForStatsPage
Execute the query against Solr and return result asStatsPage.- Parameters:
collection- must not be null.query- must not be null.clazz- must not be null.- Returns:
- never null.
- Since:
- 3.0
-
queryForStatsPage
<T> StatsPage<T> queryForStatsPage(String collection, Query query, Class<T> clazz, RequestMethod method) Execute the query against Solr and return result asStatsPage.- Parameters:
collection- must not be null.query- must not be null.clazz- must not be null.method- must not be null.- Returns:
- never null.
- Since:
- 3.0
-
query
<T,S extends org.springframework.data.domain.Page<T>> S query(String collection, Query query, Class<T> clazz) Execute the query against Solr and return result as page.- Parameters:
collection- must not be null.query- must not be null.clazz- must not be null.- Returns:
- never null.
- Since:
- 3.0
-
query
<T,S extends org.springframework.data.domain.Page<T>> S query(String collection, Query query, Class<T> clazz, RequestMethod method) Execute the query against Solr and return result as page.- Parameters:
collection- must not be null.query- must not be null.clazz- must not be null.method- must not be null.- Returns:
- never null.
- Since:
- 3.0
-
getById
Executes a realtime get using given id.- Parameters:
collection- must not be null.id- must not be null.clazz- must not be null.- Returns:
- Since:
- 3.0
-
getByIds
Executes a realtime get using given ids.- Parameters:
collection- must not be null.ids- must not be null.clazz- must not be null.- Returns:
- Since:
- 3.0
-
commit
Send commit commandSolrClient.commit()- Since:
- 3.0
-
softCommit
Send soft commmit commandSolrClient.commit(boolean, boolean, boolean)- Since:
- 3.9
-
rollback
send rollback commandSolrClient.rollback()- Since:
- 3.0
-
convertBeanToSolrInputDocument
Convert given bean into a solrj InputDocument- Parameters:
bean-- Returns:
-
getConverter
SolrConverter getConverter()- Returns:
- Converter in use
-
execute
Execute action within callback- Parameters:
action-- Returns:
-
getSchemaOperations
Get theSchemaOperationsexecutable.- Parameters:
collection-- Returns:
- never null.
- Since:
- 2.1
-