W3Cschool
恭喜您成為首批注冊(cè)用戶(hù)
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
現(xiàn)在兩種API風(fēng)格將共存,所有舊的API將繼續(xù)工作,沒(méi)有任何改變。您可以通過(guò)此-Ddisable.v2.api=true系統(tǒng)屬性啟動(dòng)您的服務(wù)器以禁用所有V2 API端點(diǎn)。
舊的API和v2 API的不同在三個(gè)主要方面體現(xiàn):
以下是一些v2 API URL路徑和路徑前綴,以及在這些路徑及其子路徑中支持的一些操作。
路徑前綴 | 一些支持的操作 |
---|---|
| 創(chuàng)建,別名,備份和恢復(fù)集合 |
| 更新請(qǐng)求 |
| 配置請(qǐng)求 |
| 架構(gòu)請(qǐng)求 |
| 處理程序特定的請(qǐng)求 |
| 拆分碎片,創(chuàng)建碎片,添加副本 |
| 刪除碎片,強(qiáng)制領(lǐng)導(dǎo)人選舉 |
| 刪除副本 |
| 創(chuàng)建一個(gè)核心 |
| 重新加載,重命名,刪除和卸載核心 |
| 執(zhí)行監(jiān)督操作,重新組織領(lǐng)導(dǎo)選舉 |
| 添加角色,刪除角色,設(shè)置集群屬性 |
| 上傳和下載blob和元數(shù)據(jù) |
附加/_introspect到任何有效的v2 API路徑,API規(guī)范將以JSON格式返回:
http://localhost:8983/api/c/_introspect
為了限制introspect輸出到僅包括一個(gè)特定的HTTP方法中,請(qǐng)?zhí)砑泳哂兄礕ET、POST或DELETE的請(qǐng)求參數(shù)method:
http://localhost:8983/api/c/_introspect?method=POST
大多數(shù)端點(diǎn)支持通過(guò)POST發(fā)送的主體中提供的命令。要將反省輸出限制為只有一個(gè)命令,請(qǐng)?zhí)砑诱?qǐng)求參數(shù):command=command-name,
http://localhost:8983/api/c/gettingstarted/_introspect?method=POST&command=modify
例如:http://localhost:8983/api/c/gettingstarted/get/_introspect
{
"spec":[{
"documentation":"https://lucene.apache.org/solr/guide/real-time-get.html",
"description":"RealTime Get allows retrieving documents by ID before the documents have been committed to the index. It is useful when you need access to documents as soon as they are indexed but your commit times are high for other reasons.",
"methods":["GET"],
"url":{
"paths":["/c/gettingstarted/get"],
"params":{
"id":{
"type":"string",
"description":"A single document ID to retrieve."},
"ids":{
"type":"string",
"description":"One or more document IDs to retrieve. Separate by commas if more than one ID is specified."},
"fq":{
"type":"string",
"description":"An optional filter query to add to the query. One use case for this is security filtering, in case users or groups should not be able to retrieve the document ID requested."}}}}],
"WARNING":"This response format is experimental. It is likely to change in the future.",
"availableSubPaths":{}
}
文檔: 此 API 的聯(lián)機(jī) Solr 參考指南部分的 URL
描述: 特征/變量/命令等的文本描述。
規(guī)范/方法: 此 API 支持的 HTTP 方法
規(guī)范/url/路徑: 此 API 支持的 url 路徑
規(guī)范/url/參數(shù): 支持的 url 請(qǐng)求參數(shù)列表
availableSubPaths: 有效 URL 路徑和 HTTP 方法的列表每個(gè)支持
對(duì)上面的例子中的一些鍵的描述:
introspect的一個(gè)POST API的例子: http://localhost:8983/api/c/gettingstarted/_introspect?method=POST&command=modify
{
"spec":[{
"documentation":"https://lucene.apache.org/solr/guide/collections-api.html",
"description":"Several collection-level operations are supported with this endpoint: modify collection attributes; reload a collection; migrate documents to a different collection; rebalance collection leaders; balance properties across shards; and add or delete a replica property.",
"methods":["POST"],
"url":{"paths":["/collections/{collection}",
"/c/{collection}"]},
"commands":{"modify":{
"documentation":"https://lucene.apache.org/solr/guide/collections-api.html#modifycollection",
"description":"Modifies specific attributes of a collection. Multiple attributes can be changed at one time.",
"type":"object",
"properties":{
"rule":{
"type":"array",
"documentation":"https://lucene.apache.org/solr/guide/rule-based-replica-placement.html",
"description":"Modifies the rules for where replicas should be located in a cluster.",
"items":{"type":"string"}},
"snitch":{
"type":"array",
"documentation":"https://lucene.apache.org/solr/guide/rule-based-replica-placement.html",
"description":"Details of the snitch provider",
"items":{"type":"string"}},
"autoAddReplicas":{
"type":"boolean",
"description":"When set to true, enables auto addition of replicas on shared file systems (such as HDFS). See https://lucene.apache.org/solr/guide/running-solr-on-hdfs.html for more details on settings and overrides."},
"replicationFactor":{
"type":"string",
"description":"The number of replicas to be created for each shard. Replicas are physical copies of each shard, acting as failover for the shard. Note that changing this value on an existing collection does not automatically add more replicas to the collection. However, it will allow add-replica commands to succeed."},
"maxShardsPerNode":{
"type":"integer",
"description":"When creating collections, the shards and/or replicas are spread across all available, live, nodes, and two replicas of the same shard will never be on the same node. If a node is not live when the collection is created, it will not get any parts of the new collection, which could lead to too many replicas being created on a single live node. Defining maxShardsPerNode sets a limit on the number of replicas can be spread to each node. If the entire collection can not be fit into the live nodes, no collection will be created at all."}}}}}],
"WARNING":"This response format is experimental. It is likely to change in the future.",
"availableSubPaths":{
"/c/gettingstarted/select":["POST", "GET"],
"/c/gettingstarted/config":["POST", "GET"],
"/c/gettingstarted/schema":["POST", "GET"],
"/c/gettingstarted/export":["POST", "GET"],
"/c/gettingstarted/admin/ping":["POST", "GET"],
"/c/gettingstarted/update":["POST"]}
}
以上示例中的"commands"部分對(duì)于此端點(diǎn)支持的每個(gè)命令都有一個(gè)條目。關(guān)鍵是命令名,值是使用JSON架構(gòu)描述命令結(jié)構(gòu)的json對(duì)象(參見(jiàn)http://json-schema.org/)。
對(duì)于“gettingstarted”集合,請(qǐng)?jiān)O(shè)置復(fù)制因子以及是否自動(dòng)添加副本(請(qǐng)參閱上面的"modify"用于此處使用的命令的introspect輸出):
$ curl http://localhost:8983/api/c/gettingstarted -H 'Content-type:application/json' -d '
{ modify: { replicationFactor: "3", autoAddReplicas: false } }'
{"responseHeader":{"status":0,"QTime":842}}
查看集群的狀態(tài):
$ curl http://localhost:8983/api/cluster
{"responseHeader":{"status":0,"QTime":0},"collections":["gettingstarted",".system"]}
設(shè)置一個(gè)集群屬性:
$ curl http://localhost:8983/api/cluster -H 'Content-type: application/json' -d '
{ set-property: { name: autoAddReplicas, val: "false" } }'
{"responseHeader":{"status":0,"QTime":4}}
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話(huà):173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: