Package org.apache.solr.servlet
Class HttpSolrCall
java.lang.Object
org.apache.solr.servlet.HttpSolrCall
- Direct Known Subclasses:
CoordinatorHttpSolrCall,V2HttpCall
This class represents a call made to Solr
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnum to define action that needs to be processed. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected HttpSolrCall.Actionprotected SolrConfigprotected SolrCoreprotected final CoreContainerprotected Stringprotected SolrRequestHandlerstatic final Stringprotected Stringprotected Stringprotected org.apache.solr.common.params.SolrParamsprotected final jakarta.servlet.http.HttpServletRequestprotected AuthorizationContext.RequestTypeprotected final jakarta.servlet.http.HttpServletResponseprotected final booleanprotected SolrQueryRequest -
Constructor Summary
ConstructorsConstructorDescriptionHttpSolrCall(CoreContainer cores, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, boolean retry) -
Method Summary
Modifier and TypeMethodDescriptionprotected Objectprotected voidaddCollectionParamIfNeeded(List<String> collections) Sets the "collection" parameter on the request to the list of alias-resolved collections for this request.call()This method processes the request.protected voidprotected voidExtract handler from the URL path if not set.protected voidextractRemotePath(String collectionName) The collection(s) to authorize this request against.The collection(s) referenced in this request.List<org.apache.solr.common.util.CommandOperation> getCommands(boolean validateInput) getCore()protected SolrCoregetCoreByCollection(String collectionName, boolean isPreferLeader) Retrieves a SolrCore instance associated with the specified collection name, with an option to prefer leader replicas.protected StringgetPath()org.apache.solr.common.params.SolrParamsIf the request has been created, return its parameters (merges URL and body if applicable); otherwise, return only the URL query parameters.protected StringgetRemoteCoreUrl(String collectionName) jakarta.servlet.http.HttpServletRequestgetReq()WARNING: This method returns a non-nullHttpServletRequest, but calling certain methods on it — such asServletRequest.getAttribute(String)— may throwNullPointerExceptionif accessed outside the original servlet thread (e.g., in asynchronous tasks).protected QueryResponseWriterReturnsQueryResponseWriterto be used.io.opentelemetry.api.trace.SpangetSpan()Get the Span for this request.protected org.apache.solr.common.util.ValidatingJsonMapgetSpec()The URL to this core, e.g.Gets the client (user-agent) SolrJ version, or null if isn't SolrJ.protected voidhandleAdmin(SolrQueryResponse solrResp) protected voidHandle a request whose "type" could not be discerned in advance and may be either "admin" or "remoteproxy".protected voidinit()protected voidlogAndFlushAdminRequest(SolrQueryResponse solrResp) protected voidnormalizeAndSetPath(String unnormalizedPath) protected voidpopulateTracingSpan(io.opentelemetry.api.trace.Span span) resolveCollectionListOrAlias(String collectionStr) Resolves the parameter as a potential comma delimited list of collections, and resolves aliases too.protected org.apache.solr.common.cloud.DocCollectionresolveDocCollection(String collectionName) Resolves the specified collection name to aDocCollectionobject.protected voidprotected voidprotected voidprotected voidwriteResponse(SolrQueryResponse solrRsp, QueryResponseWriter responseWriter, Method reqMethod)
-
Field Details
-
INTERNAL_REQUEST_COUNT
- See Also:
-
cores
-
req
protected final jakarta.servlet.http.HttpServletRequest req -
response
protected final jakarta.servlet.http.HttpServletResponse response -
retry
protected final boolean retry -
core
-
solrReq
-
handler
-
queryParams
protected org.apache.solr.common.params.SolrParams queryParams -
path
-
action
-
coreUrl
-
config
-
invalidStates
-
origCorename
-
collectionsList
-
requestType
-
-
Constructor Details
-
HttpSolrCall
public HttpSolrCall(CoreContainer cores, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, boolean retry)
-
-
Method Details
-
normalizeAndSetPath
-
getPath
-
getReq
public jakarta.servlet.http.HttpServletRequest getReq()WARNING: This method returns a non-nullHttpServletRequest, but calling certain methods on it — such asServletRequest.getAttribute(String)— may throwNullPointerExceptionif accessed outside the original servlet thread (e.g., in asynchronous tasks).Always cache required request data early during request handling if it needs to be accessed later.
-
getCore
-
getQueryParams
public org.apache.solr.common.params.SolrParams getQueryParams()If the request has been created, return its parameters (merges URL and body if applicable); otherwise, return only the URL query parameters. -
getCollectionsList
The collection(s) referenced in this request. Populated ininit(). Not null. -
getAuthorizationCollectionsList
The collection(s) to authorize this request against. In SolrCloud, when a local core serves the request, this is the collection of that core, since that is where the request executes; requests it sends to other collections are authorized by the receiving nodes. Otherwise, this isgetCollectionsList(). Not null. -
init
- Throws:
Exception
-
resolveDocCollection
Resolves the specified collection name to aDocCollectionobject. If Solr is not in cloud mode, aSolrExceptionis thrown. Returns null if the collection name is null or empty. Retrieves theDocCollectionusing theZkStateReaderfromCoreContainer. If the collection is null, updates the state by refreshing aliases and forcing a collection update. -
resolveCollectionListOrAlias
Resolves the parameter as a potential comma delimited list of collections, and resolves aliases too. One level of aliases pointing to another alias is supported. De-duplicates and retains the order.getCollectionsList() -
extractHandlerFromURLPath
Extract handler from the URL path if not set.- Throws:
Exception
-
extractRemotePath
protected void extractRemotePath(String collectionName) throws org.apache.zookeeper.KeeperException, InterruptedException, org.apache.solr.common.SolrException - Throws:
org.apache.zookeeper.KeeperExceptionInterruptedExceptionorg.apache.solr.common.SolrException
-
call
This method processes the request.- Throws:
IOException
-
handleAdminOrRemoteRequest
Handle a request whose "type" could not be discerned in advance and may be either "admin" or "remoteproxy".Some implementations (such as
V2HttpCall) may find it difficult to differentiate all request types in advance. This method serves as a hook; allowing those implementations to handle these cases gracefully.- Throws:
IOException- See Also:
-
getSpan
public io.opentelemetry.api.trace.Span getSpan()Get the Span for this request. Not null. -
populateTracingSpan
protected void populateTracingSpan(io.opentelemetry.api.trace.Span span) -
getCoreOrColName
-
sendRemoteProxy
- Throws:
IOException
-
sendError
- Throws:
IOException
-
sendError
- Throws:
IOException
-
executeCoreRequest
-
logAndFlushAdminRequest
- Throws:
IOException
-
getResponseWriter
ReturnsQueryResponseWriterto be used. WhenCommonParams.WTnot specified in the request or specified value doesn't have correspondingQueryResponseWriterthen, returns the default query response writer Note: This method must not return null -
handleAdmin
-
addCollectionParamIfNeeded
Sets the "collection" parameter on the request to the list of alias-resolved collections for this request. It can be avoided sometimes. Note:HttpShardHandlerprocesses this param.- See Also:
-
writeResponse
protected void writeResponse(SolrQueryResponse solrRsp, QueryResponseWriter responseWriter, Method reqMethod) throws IOException - Throws:
IOException
-
getCoreByCollection
Retrieves a SolrCore instance associated with the specified collection name, with an option to prefer leader replicas. Makes a call toresolveDocCollection(java.lang.String)which make an attempt to force update collection if it is not found in local cluster state -
getRemoteCoreUrl
protected String getRemoteCoreUrl(String collectionName) throws org.apache.solr.common.SolrException - Throws:
org.apache.solr.common.SolrException
-
_getHandler
-
getUserAgentSolrVersion
Gets the client (user-agent) SolrJ version, or null if isn't SolrJ. Note that older SolrJ clients prior to 9.9 present themselves as 1.0 or 2.0. -
getCommands
-
getSpec
protected org.apache.solr.common.util.ValidatingJsonMap getSpec() -
getValidators
-
getThisNodeUrl
The URL to this core, e.g.http://localhost:8983/solr.- See Also:
-