Class SolrHelper

java.lang.Object
org.tailormap.api.solr.SolrHelper
All Implemented Interfaces:
AutoCloseable, Constants

public class SolrHelper extends Object implements AutoCloseable, Constants
Solr utility/wrapper class. This class provides methods to add or update a full-text feature type index for a layer, find in the index for a layer, and clear the index for a layer. It also provides a method to close the Solr client as well as automatically closing the client when used in a try-with-resources.
  • Field Details

  • Constructor Details

    • SolrHelper

      public SolrHelper(@NotNull @NotNull org.apache.solr.client.solrj.SolrClient solrClient)
      Constructor
      Parameters:
      solrClient - the Solr client, this will be closed when this class is closed
  • Method Details

    • addFeatureTypeIndex

      public void addFeatureTypeIndex(@NotNull @NotNull SearchIndex searchIndex, @NotNull @NotNull TMFeatureType tmFeatureType, @NotNull @NotNull FeatureSourceFactoryHelper featureSourceFactoryHelper) throws UnsupportedOperationException, IOException, org.apache.solr.client.solrj.SolrServerException
      Add or update a feature type index for a layer.
      Parameters:
      searchIndex - the search index config
      tmFeatureType - the feature type
      Throws:
      UnsupportedOperationException - if the operation is not supported, possibly because not search field shave been defined
      IOException - if an I/O error occurs
      org.apache.solr.client.solrj.SolrServerException - if a Solr error occurs
    • clearIndexForLayer

      public void clearIndexForLayer(@NotNull @NotNull Long searchLayerId) throws IOException, org.apache.solr.client.solrj.SolrServerException
      Clear the index for a layer.
      Parameters:
      searchLayerId - the layer id
      Throws:
      IOException - if an I/O error occurs
      org.apache.solr.client.solrj.SolrServerException - if a Solr error occurs
    • findInIndex

      public SearchResponse findInIndex(@NotNull @NotNull SearchIndex searchIndex, String solrQuery, int start, int numResultsToReturn) throws IOException, org.apache.solr.client.solrj.SolrServerException, org.apache.solr.common.SolrException
      Search in the index for a layer. The given query is augmented to filter on the solrLayerId.
      Parameters:
      searchIndex - the search index
      solrQuery - the query, when null or empty, the query is set to * (match all)
      start - the start index, starting at 0
      numResultsToReturn - the number of results to return
      Returns:
      the documents
      Throws:
      IOException - if an I/O error occurs
      org.apache.solr.client.solrj.SolrServerException - if a Solr error occurs
      org.apache.solr.common.SolrException
    • close

      public void close() throws IOException
      Close the wrapped Solr client.
      Specified by:
      close in interface AutoCloseable
      Throws:
      IOException - if an I/O error occurs