Skip to content

Commit fae35df

Browse files
committed
[Docs] Add single request custom headers info
1 parent 6dab91a commit fae35df

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

elasticsearch-transport/README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,17 @@ You can set a custom HTTP header on the client's initializer:
234234
client = Elasticsearch::Client.new(
235235
transport_options: {
236236
headers:
237-
{user_agent: "My Ruby App"}
237+
{user_agent: "My App"}
238238
}
239239
)
240240
```
241241

242+
You can also pass in `headers` as a parameter to any of the API Endpoints to set custom headers for the request:
243+
244+
```ruby
245+
client.search(index: 'myindex', q: 'title:test', headers: {user_agent: "My App"})
246+
```
247+
242248
### Identifying running tasks with X-Opaque-Id
243249

244250
The X-Opaque-Id header allows to track certain calls, or associate certain tasks with the client that started them ([more on the Elasticsearch docs](https://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html#_identifying_running_tasks)). To use this feature, you need to set an id for `opaque_id` on the client on each request. Example:

0 commit comments

Comments
 (0)