Apache Solr open-source search software
SOLR-15739: Convert v2 GET /get API to annotations (#852)
Jason Gerlowskie57376e164b7
diff --git a/solr/core/src/java/org/apache/solr/handler/RealTimeGetHandler.java b/solr/core/src/java/org/apache/solr/handler/RealTimeGetHandler.javaindex 4858fdb59f9..9716de9f3d8 100644--- a/solr/core/src/java/org/apache/solr/handler/RealTimeGetHandler.java+++ b/solr/core/src/java/org/apache/solr/handler/RealTimeGetHandler.java@@ -16,11 +16,13 @@*/package org.apache.solr.handler;+import com.google.common.collect.Lists;import java.util.ArrayList;import java.util.Collection;import java.util.List;+import org.apache.solr.api.AnnotatedApi;import org.apache.solr.api.Api;-import org.apache.solr.api.ApiBag;+import org.apache.solr.handler.admin.api.RealTimeGetAPI;import org.apache.solr.handler.component.HttpShardHandler;import org.apache.solr.handler.component.RealTimeGetComponent;import org.apache.solr.handler.component.SearchHandler;@@ -51,7 +53,7 @@ public class RealTimeGetHandler extends SearchHandler {@Overridepublic Collection<Api> getApis() {- return ApiBag.wrapRequestHandlers(this, "core.RealtimeGet");+ return Lists.newArrayList(AnnotatedApi.getApis(new RealTimeGetAPI(this)));}@Overridediff --git a/solr/core/src/java/org/apache/solr/handler/admin/api/RealTimeGetAPI.java b/solr/core/src/java/org/apache/solr/handler/admin/api/RealTimeGetAPI.javanew file mode 100644index 00000000000..25544d02fce--- /dev/null+++ b/solr/core/src/java/org/apache/solr/handler/admin/api/RealTimeGetAPI.java@@ -0,0 +1,48 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one or more+ * contributor license agreements. See the NOTICE file distributed with+ * this work for additional information regarding copyright ownership.+ * The ASF licenses this file to You under the Apache License, Version 2.0+ * (the "License"); you may not use this file except in compliance with+ * the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+package org.apache.solr.handler.admin.api;++import static org.apache.solr.client.solrj.SolrRequest.METHOD.GET;++import org.apache.solr.api.EndPoint;+import org.apache.solr.handler.RealTimeGetHandler;+import org.apache.solr.request.SolrQueryRequest;+import org.apache.solr.response.SolrQueryResponse;+import org.apache.solr.security.PermissionNameProvider;++/**+ * V2 API for fetching the latest (possibly uncommitted) version of one or more documents.+ *+ * <p>This API (GET /v2/collections/collectionName/get) is analogous to the v1+ * /solr/collectionName/get API.+ */+public class RealTimeGetAPI {++ private final RealTimeGetHandler rtgHandler;++ public RealTimeGetAPI(RealTimeGetHandler rtgHandler) {+ this.rtgHandler = rtgHandler;+ }++ @EndPoint(+ path = {"/get"},+ method = GET,+ permission = PermissionNameProvider.Name.READ_PERM)+ public void getDocuments(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {+ rtgHandler.handleRequestBody(req, rsp);+ }+}diff --git a/solr/solrj/src/resources/apispec/core.RealtimeGet.json b/solr/solrj/src/resources/apispec/core.RealtimeGet.jsondeleted file mode 100644index b670398f41e..00000000000--- a/solr/solrj/src/resources/apispec/core.RealtimeGet.json+++ /dev/null@@ -1,26 +0,0 @@-{- "documentation": "https://solr.apache.org/guide/realtime-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": [- "/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."- }- }- }-}