Class GetRequestBuilder


A get document action request builder.
  • Constructor Details

  • Method Details

    • setType

      public GetRequestBuilder setType(@Nullable String type)
      Sets the type of the document to fetch. If set to null, will use just the id to fetch the first document matching it.
    • setId

      public GetRequestBuilder setId(String id)
      Sets the id of the document to fetch.
    • setRouting

      public GetRequestBuilder setRouting(String routing)
      Controls the shard routing of the request. Using this value to hash the shard and not the id.
    • setPreference

      public GetRequestBuilder setPreference(String preference)
      Sets the preference to execute the search. Defaults to randomize across shards. Can be set to _local to prefer local shards or a custom value, which guarantees that the same order will be used across different requests.
    • setStoredFields

      public GetRequestBuilder setStoredFields(String... fields)
      Explicitly specify the fields that will be returned. By default, the _source field will be returned.
    • setFetchSource

      public GetRequestBuilder setFetchSource(boolean fetch)
      Indicates whether the response should contain the stored _source.
      Returns:
      this for chaining
    • setFetchSource

      public GetRequestBuilder setFetchSource(@Nullable String include, @Nullable String exclude)
      Indicate that _source should be returned, with an "include" and/or "exclude" set which can include simple wildcard elements.
      Parameters:
      include - An optional include (optionally wildcarded) pattern to filter the returned _source
      exclude - An optional exclude (optionally wildcarded) pattern to filter the returned _source
    • setFetchSource

      public GetRequestBuilder setFetchSource(@Nullable String[] includes, @Nullable String[] excludes)
      Indicate that _source should be returned, with an "include" and/or "exclude" set which can include simple wildcard elements.
      Parameters:
      includes - An optional list of include (optionally wildcarded) pattern to filter the returned _source
      excludes - An optional list of exclude (optionally wildcarded) pattern to filter the returned _source
    • setRefresh

      public GetRequestBuilder setRefresh(boolean refresh)
      Should a refresh be executed before this get operation causing the operation to return the latest value. Note, heavy get should not set this to true. Defaults to false.
    • setRealtime

      public GetRequestBuilder setRealtime(boolean realtime)
    • setVersion

      public GetRequestBuilder setVersion(long version)
      Sets the version, which will cause the get operation to only be performed if a matching version exists and no changes happened on the doc since then.
    • setVersionType

      public GetRequestBuilder setVersionType(VersionType versionType)
      Sets the versioning type. Defaults to VersionType.INTERNAL.