Package org.apache.solr.client.solrj
Class SolrRequest<T>
java.lang.Object
org.apache.solr.client.solrj.SolrRequest<T>
- Type Parameters:
T- the response type, that which is returned from aprocessmethod. For V1 APIs, it's aSolrResponse.
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
AliasesApi.CreateAlias,AliasesApi.DeleteAlias,AliasesApi.GetAliasByName,AliasesApi.GetAliases,AliasPropertiesApi.CreateOrUpdateAliasProperty,AliasPropertiesApi.DeleteAliasProperty,AliasPropertiesApi.GetAliasProperty,AliasPropertiesApi.GetAllAliasProperties,AliasPropertiesApi.UpdateAliasProperties,ClusterApi.BalanceReplicas,ClusterApi.MigrateReplicas,ClusterPropertiesApi.CreateOrUpdateClusterProperty,ClusterPropertiesApi.CreateOrUpdateNestedClusterProperty,ClusterPropertiesApi.DeleteClusterProperty,ClusterPropertiesApi.GetClusterProperty,ClusterPropertiesApi.ListClusterProperties,CollectionAdminRequest,CollectionBackupsApi.CreateCollectionBackup,CollectionBackupsApi.DeleteMultipleBackupsByRecency,CollectionBackupsApi.DeleteSingleBackupById,CollectionBackupsApi.GarbageCollectUnusedBackupFiles,CollectionBackupsApi.ListBackupsAtLocation,CollectionBackupsApi.RestoreCollection,CollectionPropertiesApi.CreateOrUpdateCollectionProperty,CollectionPropertiesApi.DeleteCollectionProperty,CollectionRequiringSolrRequest,CollectionsApi.BalanceShardUnique,CollectionsApi.CreateCollection,CollectionsApi.DeleteCollection,CollectionsApi.GetCollectionStatus,CollectionsApi.ListCollections,CollectionsApi.ReloadCollection,CollectionsApi.RenameCollection,CollectionSnapshotsApi.CreateCollectionSnapshot,CollectionSnapshotsApi.DeleteCollectionSnapshot,CollectionSnapshotsApi.ListSnapshots,ConfigSetAdminRequest,ConfigsetsApi.CloneExistingConfigSet,ConfigsetsApi.DeleteConfigSet,ConfigsetsApi.ListConfigSet,ConfigsetsApi.UploadConfigSet,ConfigsetsApi.UploadConfigSetFile,CoreAdminRequest,CoreBackupsApi.CreateBackup,CoresApi.CreateCore,CoresApi.GetAllCoreStatus,CoresApi.GetCoreStatus,CoresApi.InstallCoreData,CoresApi.MergeIndexes,CoresApi.ReloadCore,CoresApi.RenameCore,CoresApi.RestoreCore,CoresApi.SwapCores,CoresApi.UnloadCore,CoreSnapshotsApi.CreateSnapshot,CoreSnapshotsApi.DeleteSnapshot,CoreSnapshotsApi.ListSnapshots1,DelegationTokenRequest,FileStoreApi.DeleteFile,FileStoreApi.FetchFile,FileStoreApi.GetFile,FileStoreApi.GetMetadata,FileStoreApi.SyncFile,FileStoreApi.UploadFile,GenericSolrRequest,HealthCheckRequest,LoggingApi.FetchLocalLogMessages,LoggingApi.ListAllLoggersAndLevels,LoggingApi.ModifyLocalLogLevel,LoggingApi.SetMessageThreshold,NodeApi.DeleteNode,NodeApi.GetCommandStatus,NodeApi.GetPublicKey,NodeApi.ReplaceNode,QueryingApi.JsonQuery,QueryingApi.Query,ReplicaPropertiesApi.AddReplicaProperty,ReplicaPropertiesApi.DeleteReplicaProperty,ReplicasApi.CreateReplica,ReplicasApi.DeleteReplicaByName,ReplicasApi.DeleteReplicasByCount,ReplicasApi.DeleteReplicasByCountAllShards,ReplicationApi.FetchFile1,ReplicationApi.FetchFileList,ReplicationApi.FetchIndexVersion,ReplicationBackupsApi.CreateBackup1,SchemaApi.AddDynamicField,SchemaApi.AddField,SchemaApi.AddFieldType,SchemaApi.BulkSchemaModification,SchemaApi.DeleteDynamicField,SchemaApi.DeleteField,SchemaApi.DeleteFieldType,SchemaApi.GetDynamicFieldInfo,SchemaApi.GetFieldInfo,SchemaApi.GetFieldTypeInfo,SchemaApi.GetSchemaInfo,SchemaApi.GetSchemaName,SchemaApi.GetSchemaSimilarity,SchemaApi.GetSchemaUniqueKey,SchemaApi.GetSchemaVersion,SchemaApi.GetSchemaZkVersion,SchemaApi.ListCopyFields,SchemaApi.ListDynamicFields,SchemaApi.ListSchemaFields,SchemaApi.ListSchemaFieldTypes,SegmentsApi.GetSegmentData,ShardsApi.CreateShard,ShardsApi.DeleteShard,ShardsApi.ForceShardLeader,ShardsApi.InstallShardData,ShardsApi.SyncShard,V2Request,ZookeeperReadApi.ListNodes,ZookeeperReadApi.ReadNode
The SolrJ base class for a request into Solr. If you create one of these, then call
process(SolrClient) to send it and get a typed response. There are some convenience methods on
SolrClient that avoids the need to even create these explicitly for common cases.- Since:
- solr 1.3
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic enumstatic enumstatic enum -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSolrRequest(SolrRequest.METHOD m, String path, SolrRequest.SolrRequestType requestType) -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidaddHeaders(Map<String, String> headers) protected abstract TcreateResponse(NamedList<Object> namedList) Create a new SolrResponse to hold the response from the server.Indicates which API version this request will makeDeprecated.getContentWriter(String expectedType) If a request object wants to do a push write, implement this method.abstract SolrParamsThe parameters for this request; never null.getPath()Parameter keys that are sent via the query stringThe type of this Solr request.final Tprocess(SolrClient client) Send this request to aSolrClientand return the responsefinal Tprocess(SolrClient client, String collection) Send this request to aSolrClientand return the responsefinal TprocessWithBaseUrl(HttpSolrClientBase client, String baseUrl, String collection) Send this request to aSolrClientand return the responsebooleanDetermines whether this request should use or ignore any specified collections (esp.setBasicAuthCredentials(String user, String password) voidsetMethod(SolrRequest.METHOD method) voidsetPreferredNodes(List<String> nodes) voidsetQueryParams(Set<String> queryParams) voidsetRequestType(SolrRequest.SolrRequestType requestType) voidsetResponseParser(ResponseParser responseParser) Optionally specify how the Response should be parsed.voidvoidsetUserPrincipal(Principal userPrincipal)
-
Field Details
-
SUPPORTED_METHODS
-
-
Constructor Details
-
SolrRequest
-
-
Method Details
-
setUserPrincipal
-
getUserPrincipal
-
setPreferredNodes
-
getPreferredNodes
-
setBasicAuthCredentials
-
getBasicAuthUser
-
getBasicAuthPassword
-
getMethod
-
setMethod
-
getPath
-
setPath
-
getResponseParser
- Returns:
- The
ResponseParser
-
setResponseParser
Optionally specify how the Response should be parsed. Not all server implementations require a ResponseParser to be specified.- Parameters:
responseParser- TheResponseParser
-
getStreamingResponseCallback
-
setStreamingResponseCallback
-
getQueryParams
Parameter keys that are sent via the query string -
setQueryParams
-
getRequestType
The type of this Solr request.Pattern matches
getPath()to identify ADMIN requests and other special cases. Overriding this method may affect request routing within various clients (i.e.CloudSolrClient). -
setRequestType
-
getParams
The parameters for this request; never null. The runtime type may be mutable but modifications may not affect thisSolrRequestinstance, as it may return a new instance here every time. If the subclass specifies the response type asModifiableSolrParams, then one can expect it to change this request. If the subclass has a setter then one can expect this method to return the value set. -
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. -
getApiVersion
Indicates which API version this request will makeDefaults implementation returns 'V1'.
-
getContentStreams
Deprecated.Please usegetContentWriter(String)instead.- Throws:
IOException
-
getContentWriter
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
Create a new SolrResponse to hold the response from the server. If the response extendsSolrResponse, then there's no need to use the arguments, asSolrResponse.setResponse(NamedList)will be called right after this method.- Parameters:
namedList- fromSolrClient.request(SolrRequest, String).
-
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
-
processWithBaseUrl
public final T processWithBaseUrl(HttpSolrClientBase client, String baseUrl, String collection) throws SolrServerException, IOException Send this request to aSolrClientand return the response- Parameters:
client- the SolrClient to communicate withbaseUrl- the base URL, e.g.Http://localhost:8983/solrcollection- 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- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
process
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
-
addHeader
-
addHeaders
-
getHeaders
-
getContentWriter(String)instead.