Skip to content

Instantly share code, notes, and snippets.

@drewr
Created October 23, 2013 14:52
Show Gist options
  • Save drewr/7120257 to your computer and use it in GitHub Desktop.
Save drewr/7120257 to your computer and use it in GitHub Desktop.
Example of X-Opaque-Id
#!/bin/sh
curl -XDELETE localhost:9200/foo >/dev/null
curl -XPUT localhost:9200/foo/t/1 -d'{"field":"value"}'; echo
curl -XPOST localhost:9200/foo/_refresh; echo
curl -v -H X-Opaque-Id:FOOOOOOO localhost:9200/foo/_search; echo
## {"ok":true,"_index":"foo","_type":"t","_id":"1","_version":1}
## {"ok":true,"_shards":{"total":10,"successful":5,"failed":0}}
## * About to connect() to localhost port 9200 (#0)
## * Trying ::1...
## * Connection refused
## * Trying 127.0.0.1...
## * connected
## * Connected to localhost (127.0.0.1) port 9200 (#0)
## > GET /foo/_search HTTP/1.1
## > User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8y zlib/1.2.5
## > Host: localhost:9200
## > Accept: */*
## > X-Opaque-Id:FOOOOOOO <------------ request
## >
## < HTTP/1.1 200 OK
## < X-Opaque-Id: FOOOOOOO <------------ response
## < Content-Type: application/json; charset=UTF-8
## < Content-Length: 203
## <
## { [data not shown]
## * Connection #0 to host localhost left intact
## {"took":1,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1,"max_score":1.0,"hits":[{"_index":"foo","_type":"t","_id":"1","_score":1.0, "_source" : {"field":"value"}}]}}* Closing connection #0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment