Package org.apache.solr.client.solrj
Class SolrRequest<T extends SolrResponse>
- java.lang.Object
-
- org.apache.solr.client.solrj.SolrRequest<T>
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
AliasesApi.DeleteAlias,AliasesApi.GetAliasByName,AliasesApi.GetAliases,AliasPropertiesApi.CreateOrUpdateAliasProperty,AliasPropertiesApi.DeleteAliasProperty,AliasPropertiesApi.GetAliasProperty,AliasPropertiesApi.GetAllAliasProperties,AliasPropertiesApi.UpdateAliasProperties,ClusterApi.BalanceReplicas,ClusterApi.MigrateReplicas,CollectionAdminRequest,CollectionBackupsApi.CreateCollectionBackup,CollectionBackupsApi.DeleteMultipleBackupsByRecency,CollectionBackupsApi.DeleteSingleBackupById,CollectionBackupsApi.GarbageCollectUnusedBackupFiles,CollectionBackupsApi.ListBackupsAtLocation,CollectionPropertiesApi.CreateOrUpdateCollectionProperty,CollectionPropertiesApi.DeleteCollectionProperty,CollectionRequiringSolrRequest,CollectionsApi.BalanceShardUnique,CollectionsApi.CreateCollection,CollectionsApi.DeleteCollection,CollectionsApi.ListCollections,CollectionsApi.ReloadCollection,CollectionsApi.RenameCollection,CollectionSnapshotsApi.CreateCollectionSnapshot,CollectionSnapshotsApi.DeleteCollectionSnapshot,ConfigSetAdminRequest,ConfigsetsApi.ListConfigSet,CoreAdminRequest,CoreBackupsApi.CreateBackup,CoresApi.InstallCoreData,CoresApi.MergeIndexes,CoresApi.ReloadCore,CoresApi.RenameCore,CoresApi.RestoreCore,CoresApi.SwapCores,CoresApi.UnloadCore,CoreSnapshotsApi.CreateSnapshot,CoreSnapshotsApi.DeleteSnapshot,CoreSnapshotsApi.ListSnapshots,DelegationTokenRequest,GenericSolrRequest,HealthCheckRequest,NodeApi.DeleteNode,NodeApi.GetCommandStatus,NodeApi.GetPublicKey,NodeApi.ReplaceNode,QueryingApi.JsonQuery,QueryingApi.Query,ReplicaPropertiesApi.AddReplicaProperty,ReplicaPropertiesApi.DeleteReplicaProperty,ReplicasApi.CreateReplica,ReplicasApi.DeleteReplicaByName,ReplicasApi.DeleteReplicasByCount,ReplicasApi.DeleteReplicasByCountAllShards,SchemaApi.GetSchemaInfo,SchemaApi.GetSchemaName,SchemaApi.GetSchemaSimilarity,SchemaApi.GetSchemaUniqueKey,SchemaApi.GetSchemaVersion,SchemaApi.GetSchemaZkVersion,ShardsApi.CreateShard,ShardsApi.DeleteShard,ShardsApi.ForceShardLeader,ShardsApi.InstallShardData,ShardsApi.SyncShard,V2Request
public abstract class SolrRequest<T extends SolrResponse> extends Object implements Serializable
- Since:
- solr 1.3
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSolrRequest.METHODstatic classSolrRequest.SolrClientContextstatic classSolrRequest.SolrRequestType
-
Field Summary
Fields Modifier and Type Field Description static Set<String>SUPPORTED_METHODSprotected booleanuseBinaryV2protected booleanusev2
-
Constructor Summary
Constructors Constructor Description SolrRequest(SolrRequest.METHOD m, String path)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddHeader(String key, String value)voidaddHeaders(Map<String,String> headers)protected abstract TcreateResponse(SolrClient client)Create a new SolrResponse to hold the response from the serverStringgetBasePath()StringgetBasicAuthPassword()StringgetBasicAuthUser()StringgetCollection()Collection<ContentStream>getContentStreams()Deprecated.Please usegetContentWriter(String)instead.RequestWriter.ContentWritergetContentWriter(String expectedType)If a request object wants to do a push write, implement this method.Map<String,String>getHeaders()SolrRequest.METHODgetMethod()abstract SolrParamsgetParams()StringgetPath()List<String>getPreferredNodes()Set<String>getQueryParams()Parameter keys that are sent via the query stringabstract StringgetRequestType()This method defines the type of this Solr request.ResponseParsergetResponseParser()StreamingResponseCallbackgetStreamingResponseCallback()PrincipalgetUserPrincipal()Tprocess(SolrClient client)Send this request to aSolrClientand return the responseTprocess(SolrClient client, String collection)Send this request to aSolrClientand return the responsebooleanrequiresCollection()Determines whether this request should use or ignore any specified collections (esp.voidsetBasePath(String path)SolrRequest<T>setBasicAuthCredentials(String user, String password)voidsetMethod(SolrRequest.METHOD method)voidsetPath(String path)SolrRequest<T>setPreferredNodes(List<String> nodes)voidsetQueryParams(Set<String> queryParams)voidsetResponseParser(ResponseParser responseParser)Optionally specify how the Response should be parsed.voidsetStreamingResponseCallback(StreamingResponseCallback callback)SolrRequest<T>setUseBinaryV2(boolean flag)Deprecated.use v2-nativeSolrRequestimplementations directly insteadvoidsetUserPrincipal(Principal userPrincipal)SolrRequest<T>setUseV2(boolean flag)Deprecated.use v2-nativeSolrRequestimplementations directly instead
-
-
-
Constructor Detail
-
SolrRequest
public SolrRequest(SolrRequest.METHOD m, String path)
-
-
Method Detail
-
setUserPrincipal
public void setUserPrincipal(Principal userPrincipal)
-
getUserPrincipal
public Principal getUserPrincipal()
-
setUseV2
@Deprecated public SolrRequest<T> setUseV2(boolean flag)
Deprecated.use v2-nativeSolrRequestimplementations directly insteadIf set to true, every request that implementsV2RequestSupportwill be converted to a V2 API call
-
setUseBinaryV2
@Deprecated public SolrRequest<T> setUseBinaryV2(boolean flag)
Deprecated.use v2-nativeSolrRequestimplementations directly insteadIf set to true use javabin instead of json (default)
-
setPreferredNodes
public SolrRequest<T> setPreferredNodes(List<String> nodes)
-
setBasicAuthCredentials
public SolrRequest<T> setBasicAuthCredentials(String user, String password)
-
getBasicAuthUser
public String getBasicAuthUser()
-
getBasicAuthPassword
public String getBasicAuthPassword()
-
getMethod
public SolrRequest.METHOD getMethod()
-
setMethod
public void setMethod(SolrRequest.METHOD method)
-
getPath
public String getPath()
-
setPath
public void setPath(String path)
-
getResponseParser
public ResponseParser getResponseParser()
- Returns:
- The
ResponseParser
-
setResponseParser
public void setResponseParser(ResponseParser responseParser)
Optionally specify how the Response should be parsed. Not all server implementations require a ResponseParser to be specified.- Parameters:
responseParser- TheResponseParser
-
getStreamingResponseCallback
public StreamingResponseCallback getStreamingResponseCallback()
-
setStreamingResponseCallback
public void setStreamingResponseCallback(StreamingResponseCallback callback)
-
getQueryParams
public Set<String> getQueryParams()
Parameter keys that are sent via the query string
-
getRequestType
public abstract String getRequestType()
This method defines the type of this Solr request.
-
getParams
public abstract SolrParams getParams()
-
requiresCollection
public boolean requiresCollection()
Determines whether this request should use or ignore any specified collections (esp.SolrClient.defaultCollection)Many Solr requests target a particular core or collection. But not all of them - many Solr APIs (e.g. security or other admin APIs) are agnostic of collections entirely. This method gives these requests a way to opt out of using
SolrClient.defaultCollectionor other specified collections.
-
getContentStreams
@Deprecated public Collection<ContentStream> getContentStreams() throws IOException
Deprecated.Please usegetContentWriter(String)instead.- Throws:
IOException
-
getContentWriter
public RequestWriter.ContentWriter getContentWriter(String expectedType)
If a request object wants to do a push write, implement this method.- Parameters:
expectedType- This is the type that the RequestWriter would like to get. But, it is OK to send any format
-
createResponse
protected abstract T createResponse(SolrClient client)
Create a new SolrResponse to hold the response from the server- Parameters:
client- theSolrClientthe request will be sent to
-
process
public final T process(SolrClient client, String collection) throws SolrServerException, IOException
Send this request to aSolrClientand return the response- Parameters:
client- the SolrClient to communicate withcollection- the collection to execute the request against- Returns:
- the response
- Throws:
SolrServerException- if there is an error on the Solr serverIOException- if there is a communication error
-
process
public final T process(SolrClient client) throws SolrServerException, IOException
Send this request to aSolrClientand return the response- Parameters:
client- the SolrClient to communicate with- Returns:
- the response
- Throws:
SolrServerException- if there is an error on the Solr serverIOException- if there is a communication error
-
getCollection
public String getCollection()
-
setBasePath
public void setBasePath(String path)
-
getBasePath
public String getBasePath()
-
-