Class RestSearchAction

java.lang.Object
org.elasticsearch.rest.BaseRestHandler
org.elasticsearch.rest.action.search.RestSearchAction
All Implemented Interfaces:
RestHandler

public class RestSearchAction
extends BaseRestHandler
  • Field Details

    • TOTAL_HITS_AS_INT_PARAM

      public static final java.lang.String TOTAL_HITS_AS_INT_PARAM
      Indicates whether hits.total should be rendered as an integer or an object in the rest search response.
      See Also:
      Constant Field Values
    • TYPED_KEYS_PARAM

      public static final java.lang.String TYPED_KEYS_PARAM
      See Also:
      Constant Field Values
    • TYPES_DEPRECATION_MESSAGE

      public static final java.lang.String TYPES_DEPRECATION_MESSAGE
      See Also:
      Constant Field Values
  • Constructor Details

    • RestSearchAction

      public RestSearchAction()
  • Method Details

    • getName

      public java.lang.String getName()
      Specified by:
      getName in class BaseRestHandler
      Returns:
      the name of this handler. The name should be human readable and should describe the action that will performed when this API is called. This name is used in the response to the RestNodesUsageAction.
    • routes

      public java.util.List<RestHandler.Route> routes()
      Description copied from class: BaseRestHandler
      The list of RestHandler.Routes that this RestHandler is responsible for handling.
      Specified by:
      routes in interface RestHandler
      Specified by:
      routes in class BaseRestHandler
    • prepareRequest

      public BaseRestHandler.RestChannelConsumer prepareRequest​(RestRequest request, NodeClient client) throws java.io.IOException
      Description copied from class: BaseRestHandler
      Prepare the request for execution. Implementations should consume all request params before returning the runnable for actual execution. Unconsumed params will immediately terminate execution of the request. However, some params are only used in processing the response; implementations can override BaseRestHandler.responseParams() to indicate such params.
      Specified by:
      prepareRequest in class BaseRestHandler
      Parameters:
      request - the request to execute
      client - client for executing actions on the local node
      Returns:
      the action to execute
      Throws:
      java.io.IOException - if an I/O exception occurred parsing the request and preparing for execution
    • parseSearchRequest

      public static void parseSearchRequest​(SearchRequest searchRequest, RestRequest request, org.elasticsearch.common.xcontent.XContentParser requestContentParser, NamedWriteableRegistry namedWriteableRegistry, java.util.function.IntConsumer setSize) throws java.io.IOException
      Parses the rest request on top of the SearchRequest, preserving values that are not overridden by the rest request.
      Parameters:
      requestContentParser - body of the request to read. This method does not attempt to read the body from the request parameter
      setSize - how the size url parameter is handled. udpate_by_query and regular search differ here.
      Throws:
      java.io.IOException
    • checkRestTotalHits

      public static void checkRestTotalHits​(RestRequest restRequest, SearchRequest searchRequest)
      Modify the search request to accurately count the total hits that match the query if TOTAL_HITS_AS_INT_PARAM is set.
      Throws:
      java.lang.IllegalArgumentException - if TOTAL_HITS_AS_INT_PARAM is used in conjunction with a lower bound value (other than SearchContext.DEFAULT_TRACK_TOTAL_HITS_UP_TO) for the track_total_hits option.
    • responseParams

      protected java.util.Set<java.lang.String> responseParams()
      Description copied from class: BaseRestHandler
      Parameters used for controlling the response and thus might not be consumed during preparation of the request execution in BaseRestHandler.prepareRequest(RestRequest, NodeClient).
      Overrides:
      responseParams in class BaseRestHandler
      Returns:
      a set of parameters used to control the response and thus should not trip strict URL parameter checks.
    • allowsUnsafeBuffers

      public boolean allowsUnsafeBuffers()
      Description copied from interface: RestHandler
      Indicates if the RestHandler supports working with pooled buffers. If the request handler will not escape the return RestRequest.content() or any buffers extracted from it then there is no need to make a copies of any pooled buffers in the RestRequest instance before passing a request to this handler. If this instance does not support pooled/unsafe buffers RestRequest.ensureSafeBuffers() should be called on any request before passing it to RestHandler.handleRequest(org.elasticsearch.rest.RestRequest, org.elasticsearch.rest.RestChannel, org.elasticsearch.client.node.NodeClient).
      Returns:
      true iff the handler supports requests that make use of pooled buffers