Package org.mycore.solr.search
Class MCRSolrURL
java.lang.Object
org.mycore.solr.search.MCRSolrURL
Convenience class for holding the parameters for the solr search url.
- Author:
- shermann
-
Field Summary
-
Constructor Summary
ConstructorDescriptionMCRSolrURL
(org.apache.solr.client.solrj.impl.HttpSolrClient solrClient) MCRSolrURL
(org.apache.solr.client.solrj.impl.HttpSolrClient solrClient, boolean returnScore) MCRSolrURL
(org.apache.solr.client.solrj.impl.HttpSolrClient solrClient, String urlQuery) Creates a new solr url using your own url query. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addSortOption
(String sort) Adds a sort option to the solr urlvoid
addSortOption
(String sortBy, String order) Adds a sort option to the solr url.Invoke this method to get aURL
referring to the luke interface of a solr server.Returns the current request handler.int
getRows()
int
getStart()
getUrl()
An abbreviation for getUrl().openStream();boolean
void
setQueryParamter
(String query) Sets the unencoded query parameter.void
setRequestHandler
(String requestHandler) Sets the solr request handler.void
setReturnScore
(boolean yesOrNo) void
setRows
(int rows) Sets the rows parameter.void
setStart
(int start) Sets the start parameter.void
setWriterType
(String wt) The wt (writer type) parameter is used by Solr to determine which QueryResponseWriter should be used to process the request.
-
Field Details
-
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
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 useurlQuery
- 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 usereturnScore
- specify whether to return the score with results;
-
-
Method Details
-
getUrl
- Returns:
- a ready to invoke
URL
object or null
-
getLukeURL
Invoke this method to get aURL
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
An abbreviation for getUrl().openStream();- Throws:
IOException
-
addSortOption
Adds a sort option to the solr url.- Parameters:
sortBy
- the name of the field to sort byorder
- the sort order, one can useSolrQuery.ORDER.asc
orSolrQuery.ORDER.desc
-
addSortOption
Adds a sort option to the solr url- Parameters:
sort
- the sort option e.g. 'maintitle desc'
-
setQueryParamter
Sets the unencoded query parameter. -
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
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
Sets the solr request handler.- Parameters:
requestHandler
- the name of the request handler to set e.g. /foo
-
getRequestHandler
Returns the current request handler.- Returns:
- the solr request handler
-