Interface SolrOperations

All Known Implementing Classes:
SolrTemplate

public interface SolrOperations
Interface that specifies a basic set of Solr operations.
  • Method Details

    • getSolrClient

      org.apache.solr.client.solrj.SolrClient getSolrClient()
      Get the underlying SolrClient instance
      Returns:
      the SolrClient in use. Never null.
    • ping

      org.apache.solr.client.solrj.response.SolrPingResponse ping()
      Execute ping against SolrClient and return duration in msec
      Returns:
      SolrPingResponse containing ping result.
      Throws:
      org.springframework.dao.DataAccessResourceFailureException - if ping fails.
    • ping

      org.apache.solr.client.solrj.response.SolrPingResponse ping(String collection)
      Execute ping against SolrClient and return duration in msec
      Parameters:
      collection - must not be null.
      Returns:
      SolrPingResponse containing ping result.
      Throws:
      org.springframework.dao.DataAccessResourceFailureException - if ping fails.
      Since:
      3.0
    • count

      default long count(String collection, SolrDataQuery query)
      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

      long count(String collection, SolrDataQuery query, @Nullable Class<?> domainType)
      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

      default long count(String collection, SolrDataQuery query, RequestMethod method)
      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:
      UpdateResponse containing 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:
      UpdateResponse containing 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:
      UpdateResponse containing 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:
      UpdateResponse containing 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:
      UpdateResponse containing 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:
      UpdateResponse containing 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:
      UpdateResponse containing 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:
      UpdateResponse containing 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:
      UpdateResponse containing 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:
      UpdateResponse containing delete result.
      Since:
      4.0
    • deleteByIds

      org.apache.solr.client.solrj.response.UpdateResponse deleteByIds(String collection, String id)
      Detele the one object with provided id.
      Parameters:
      collection - must not be null.
      id - must not be null.
      Returns:
      UpdateResponse containing 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:
      UpdateResponse containing delete result.
      Since:
      3.0
    • queryForObject

      <T> Optional<T> queryForObject(String collection, Query query, Class<T> clazz)
      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

      <T> ScoredPage<T> queryForPage(String collection, Query query, Class<T> clazz)
      Execute the query against solr and retrun 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
    • queryForPage

      <T> ScoredPage<T> queryForPage(String collection, Query query, Class<T> clazz, RequestMethod method)
      Execute the query against solr and retrun 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
    • queryForFacetPage

      <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
      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

      <T> HighlightPage<T> queryForHighlightPage(String collection, HighlightQuery 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
    • 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

      TermsPage queryForTermsPage(String collection, TermsQuery query)
      Execute query using terms handler
      Parameters:
      collection - must not be null.
      query - must not be null.
      Returns:
      never null.
      Since:
      3.0
    • queryForTermsPage

      TermsPage queryForTermsPage(String collection, TermsQuery query, RequestMethod method)
      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

      <T> Cursor<T> queryForCursor(String collection, Query query, Class<T> clazz)
      Executes the given Query and returns an open Cursor allowing 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

      <T> GroupPage<T> queryForGroupPage(String collection, Query query, Class<T> clazz)
      Execute the query against solr and return result as GroupPage
      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 as GroupPage
      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

      <T> StatsPage<T> queryForStatsPage(String collection, Query query, Class<T> clazz)
      Execute the query against Solr and return result as StatsPage.
      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 as StatsPage.
      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

      <T> Optional<T> getById(String collection, Object id, Class<T> clazz)
      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

      <T> Collection<T> getByIds(String collection, Collection<?> ids, Class<T> clazz)
      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

      void commit(String collection)
      Send commit command SolrClient.commit()
      Since:
      3.0
    • softCommit

      void softCommit(String collection)
      Send soft commmit command SolrClient.commit(boolean, boolean, boolean)
      Since:
      3.9
    • rollback

      void rollback(String collection)
      send rollback command SolrClient.rollback()
      Since:
      3.0
    • convertBeanToSolrInputDocument

      org.apache.solr.common.SolrInputDocument convertBeanToSolrInputDocument(Object bean)
      Convert given bean into a solrj InputDocument
      Parameters:
      bean -
      Returns:
    • getConverter

      SolrConverter getConverter()
      Returns:
      Converter in use
    • execute

      <T> T execute(SolrCallback<T> action)
      Execute action within callback
      Parameters:
      action -
      Returns:
    • getSchemaOperations

      SchemaOperations getSchemaOperations(String collection)
      Get the SchemaOperations executable.
      Parameters:
      collection -
      Returns:
      never null.
      Since:
      2.1