Class MCRSolrURL

java.lang.Object
org.mycore.solr.search.MCRSolrURL

public class MCRSolrURL extends Object
Convenience class for holding the parameters for the solr search url.
Author:
shermann
  • Field Details

    • FIXED_URL_PART

      public static final String FIXED_URL_PART
  • Constructor Details

    • MCRSolrURL

      public MCRSolrURL(org.apache.solr.client.solrj.impl.HttpSolrClient solrClient)
      Parameters:
      solrClient - the solr server connection to use
    • MCRSolrURL

      public MCRSolrURL(org.apache.solr.client.solrj.impl.HttpSolrClient solrClient, String urlQuery)
      Creates a new solr url using your own url query. Be aware that you cannot use the MCRSolrURL setter methods to edit your request. Only the urlQuery is used.
      Parameters:
      solrClient - the solr server connection to use
      urlQuery - e.g. q=allMeta:Hello&rows=20&defType=edismax
    • MCRSolrURL

      public MCRSolrURL(org.apache.solr.client.solrj.impl.HttpSolrClient solrClient, boolean returnScore)
      Parameters:
      solrClient - the solr server connection to use
      returnScore - specify whether to return the score with results;
  • Method Details

    • getUrl

      public URL getUrl()
      Returns:
      a ready to invoke URL object or null
    • getLukeURL

      public URL getLukeURL()
      Invoke this method to get a URL referring to the luke interface of a solr server. Under this URL one can find useful information about the solr schema.
      Returns:
      a URL refering to the luke interface or null
    • openStream

      public InputStream openStream() throws IOException
      An abbreviation for getUrl().openStream();
      Throws:
      IOException
    • addSortOption

      public void addSortOption(String sortBy, String order)
      Adds a sort option to the solr url.
      Parameters:
      sortBy - the name of the field to sort by
      order - the sort order, one can use SolrQuery.ORDER.asc or SolrQuery.ORDER.desc
    • addSortOption

      public void addSortOption(String sort)
      Adds a sort option to the solr url
      Parameters:
      sort - the sort option e.g. 'maintitle desc'
    • setQueryParamter

      public void setQueryParamter(String query)
      Sets the unencoded query parameter.
    • getQueryParamter

      public String getQueryParamter()
      Returns:
      the query parameter
    • getStart

      public int getStart()
      Returns:
      the start parameter
    • getRows

      public int getRows()
      Returns:
      the rows parameter
    • setStart

      public void setStart(int start)
      Sets the start parameter.
    • setRows

      public void setRows(int rows)
      Sets the rows parameter.
    • setReturnScore

      public void setReturnScore(boolean yesOrNo)
    • setWriterType

      public void setWriterType(String wt)
      The wt (writer type) parameter is used by Solr to determine which QueryResponseWriter should be used to process the request. Valid values are any of the names specified by <queryResponseWriter... /> declarations in solrconfig.xml. The default value is "standard" (xml).
    • returnsScore

      public boolean returnsScore()
      Returns:
      true if the score is returned with the results, false otherwise
    • setRequestHandler

      public void setRequestHandler(String requestHandler)
      Sets the solr request handler.
      Parameters:
      requestHandler - the name of the request handler to set e.g. /foo
    • getRequestHandler

      public String getRequestHandler()
      Returns the current request handler.
      Returns:
      the solr request handler