From c8e0e939e496d0e77994e010d1eb436613dd66b7 Mon Sep 17 00:00:00 2001 From: Ishan Chattopadhyaya Date: Sun, 20 Aug 2017 21:00:15 +0530 Subject: [PATCH] SOLR-11183: V2 APIs are now available at /api endpoint --- dev-tools/scripts/smokeTestRelease.py | 2 +- solr/CHANGES.txt | 5 +++ solr/server/etc/jetty.xml | 8 ++++ solr/solr-ref-guide/src/v2-api.adoc | 42 +++++++++---------- .../client/solrj/impl/HttpSolrClient.java | 2 +- 5 files changed, 36 insertions(+), 23 deletions(-) diff --git a/dev-tools/scripts/smokeTestRelease.py b/dev-tools/scripts/smokeTestRelease.py index 01706a7d4e7..b7ca9720a72 100644 --- a/dev-tools/scripts/smokeTestRelease.py +++ b/dev-tools/scripts/smokeTestRelease.py @@ -861,7 +861,7 @@ def testSolrExample(unpackPath, javaPath, isSrc): if s.find('"numFound":3,"start":0') == -1: print('FAILED: response is:\n%s' % s) raise RuntimeError('query on solr example instance failed') - s = load('http://localhost:8983/v2/cores') + s = load('http://localhost:8983/api/cores') if s.find('"status":0,') == -1: print('FAILED: response is:\n%s' % s) raise RuntimeError('query api v2 on solr example instance failed') diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index d07b0850bc5..a910fc60c2b 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -294,6 +294,9 @@ Upgrading from Solr 6.x * SOLR-11239: The use of maxShardsPerNode is not supported when a cluster policy is in effect or when a collection specific policy is specified during collection creation. +* V2 APIs are now available at /api, in addition to /v2 (which is now deprecated). Legacy APIs continue to remain + available at /solr. + New Features ---------------------- * SOLR-9857, SOLR-9858: Collect aggregated metrics from nodes and shard leaders in overseer. (ab) @@ -678,6 +681,8 @@ Other Changes collection specific policy is specified during collection creation. (Noble Paul, shalin) +* SOLR-11183: V2 APIs are now available at /api endpoint. (Ishan Chattopadhyaya) + ================== 6.7.0 ================== Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release. diff --git a/solr/server/etc/jetty.xml b/solr/server/etc/jetty.xml index b512c51a8d1..1f6de775a49 100644 --- a/solr/server/etc/jetty.xml +++ b/solr/server/etc/jetty.xml @@ -105,6 +105,14 @@ + + + + /api/* + /solr/____v2 + + + diff --git a/solr/solr-ref-guide/src/v2-api.adoc b/solr/solr-ref-guide/src/v2-api.adoc index 15e1fda570c..6fbc168faf8 100644 --- a/solr/solr-ref-guide/src/v2-api.adoc +++ b/solr/solr-ref-guide/src/v2-api.adoc @@ -41,38 +41,38 @@ Following are some v2 API URL paths and path prefixes, along with some of the op [width="100%",options="header",] |=== |Path prefix |Some Supported Operations -|`/v2/collections` or equivalently: `/v2/c` |Create, alias, backup, and restore a collection. -|`/v2/c/_collection-name_/update` |Update requests. -|`/v2/c/_collection-name_/config` |Configuration requests. -|`/v2/c/_collection-name_/schema` |Schema requests. -|`/v2/c/_collection-name_/_handler-name_` |Handler-specific requests. -|`/v2/c/_collection-name_/shards` |Split a shard, create a shard, add a replica. -|`/v2/c/_collection-name_/shards/_shard-name_` |Delete a shard, force leader election -|`/v2/c/_collection-name_/shards/_shard-name_/_replica-name_` |Delete a replica. -|`/v2/cores` |Create a core. -|`/v2/cores/_core-name_` |Reload, rename, delete, and unload a core. -|`/v2/node` |Perform overseer operation, rejoin leader election. -|`/v2/cluster` |Add role, remove role, set cluster property. -|`/v2/c/.system/blob` |Upload and download blobs and metadata. +|`/api/collections` or equivalently: `/api/c` |Create, alias, backup, and restore a collection. +|`/api/c/_collection-name_/update` |Update requests. +|`/api/c/_collection-name_/config` |Configuration requests. +|`/api/c/_collection-name_/schema` |Schema requests. +|`/api/c/_collection-name_/_handler-name_` |Handler-specific requests. +|`/api/c/_collection-name_/shards` |Split a shard, create a shard, add a replica. +|`/api/c/_collection-name_/shards/_shard-name_` |Delete a shard, force leader election +|`/api/c/_collection-name_/shards/_shard-name_/_replica-name_` |Delete a replica. +|`/api/cores` |Create a core. +|`/api/cores/_core-name_` |Reload, rename, delete, and unload a core. +|`/api/node` |Perform overseer operation, rejoin leader election. +|`/api/cluster` |Add role, remove role, set cluster property. +|`/api/c/.system/blob` |Upload and download blobs and metadata. |=== == Introspect Append `/_introspect` to any valid v2 API path and the API specification will be returned in JSON format. -`\http://localhost:8983/v2/c/_introspect` +`\http://localhost:8983/api/c/_introspect` To limit the introspect output to include just one particular HTTP method, add request param `method` with value `GET`, `POST`, or `DELETE`. -`\http://localhost:8983/v2/c/_introspect?method=POST` +`\http://localhost:8983/api/c/_introspect?method=POST` Most endpoints support commands provided in a body sent via POST. To limit the introspect output to only one command, add request param `command=_command-name_` . -`\http://localhost:8983/v2/c/gettingstarted/_introspect?method=POST&command=modify` +`\http://localhost:8983/api/c/gettingstarted/_introspect?method=POST&command=modify` === Interpreting the Introspect Output -Example : `\http://localhost:8983/v2/c/gettingstarted/get/_introspect` +Example : `\http://localhost:8983/api/c/gettingstarted/get/_introspect` [source,json] ---- @@ -107,7 +107,7 @@ Description of some of the keys in the above example: * `**spec/url/params**` : List of supported URL request params * `**availableSubPaths**` : List of valid URL subpaths and the HTTP method(s) each supports -Example of introspect for a POST API: `\http://localhost:8983/v2/c/gettingstarted/_introspect?method=POST&command=modify` +Example of introspect for a POST API: `\http://localhost:8983/api/c/gettingstarted/_introspect?method=POST&command=modify` [source,json] ---- @@ -161,7 +161,7 @@ For the "gettingstarted" collection, set the replication factor and whether to a [source,bash] ---- -$ curl http://localhost:8983/v2/c/gettingstarted -H 'Content-type:application/json' -d ' +$ curl http://localhost:8983/api/c/gettingstarted -H 'Content-type:application/json' -d ' { modify: { replicationFactor: "3", autoAddReplicas: false } }' {"responseHeader":{"status":0,"QTime":842}} @@ -171,7 +171,7 @@ See the state of the cluster: [source,bash] ---- -$ curl http://localhost:8983/v2/cluster +$ curl http://localhost:8983/api/cluster {"responseHeader":{"status":0,"QTime":0},"collections":["gettingstarted",".system"]} ---- @@ -180,7 +180,7 @@ Set a cluster property: [source,bash] ---- -$ curl http://localhost:8983/v2/cluster -H 'Content-type: application/json' -d ' +$ curl http://localhost:8983/api/cluster -H 'Content-type: application/json' -d ' { set-property: { name: autoAddReplicas, val: "false" } }' {"responseHeader":{"status":0,"QTime":4}} diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrClient.java index 02d7c1a61ed..b18a9b31702 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrClient.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrClient.java @@ -355,7 +355,7 @@ public class HttpSolrClient extends SolrClient { if (request instanceof V2Request) { if (System.getProperty("solr.v2RealPath") == null) { - basePath = baseUrl.replace("/solr", "/v2"); + basePath = baseUrl.replace("/solr", "/api"); } else { basePath = baseUrl + "/____v2"; }