query-api-key.asciidoc 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774
  1. [role="xpack"]
  2. [[security-api-query-api-key]]
  3. === Query API key information API
  4. ++++
  5. <titleabbrev>Query API key information</titleabbrev>
  6. ++++
  7. ////
  8. [source,console]
  9. ----
  10. POST /_security/user/king
  11. {
  12. "password" : "security-test-password",
  13. "roles": []
  14. }
  15. POST /_security/user/june
  16. {
  17. "password" : "security-test-password",
  18. "roles": []
  19. }
  20. POST /_security/api_key/grant
  21. {
  22. "grant_type": "password",
  23. "username" : "king",
  24. "password" : "security-test-password",
  25. "api_key" : {
  26. "name": "king-key-no-expire"
  27. }
  28. }
  29. DELETE /_security/api_key
  30. {
  31. "name" : "king-key-no-expire"
  32. }
  33. POST /_security/api_key/grant
  34. {
  35. "grant_type": "password",
  36. "username" : "king",
  37. "password" : "security-test-password",
  38. "api_key" : {
  39. "name": "king-key-10",
  40. "expiration": "10d"
  41. }
  42. }
  43. POST /_security/api_key/grant
  44. {
  45. "grant_type": "password",
  46. "username" : "king",
  47. "password" : "security-test-password",
  48. "api_key" : {
  49. "name": "king-key-100",
  50. "expiration": "100d"
  51. }
  52. }
  53. POST /_security/api_key/grant
  54. {
  55. "grant_type": "password",
  56. "username" : "june",
  57. "password" : "security-test-password",
  58. "api_key" : {
  59. "name": "june-key-no-expire"
  60. }
  61. }
  62. POST /_security/api_key/grant
  63. {
  64. "grant_type": "password",
  65. "username" : "june",
  66. "password" : "security-test-password",
  67. "api_key" : {
  68. "name": "june-key-10",
  69. "expiration": "10d"
  70. }
  71. }
  72. POST /_security/api_key/grant
  73. {
  74. "grant_type": "password",
  75. "username" : "june",
  76. "password" : "security-test-password",
  77. "api_key" : {
  78. "name": "june-key-100",
  79. "expiration": "100d"
  80. }
  81. }
  82. DELETE /_security/api_key
  83. {
  84. "name" : "june-key-100"
  85. }
  86. ----
  87. // TESTSETUP
  88. [source,console]
  89. --------------------------------------------------
  90. DELETE /_security/user/king
  91. DELETE /_security/user/june
  92. DELETE /_security/api_key
  93. {
  94. "name" : "king-key-no-expire"
  95. }
  96. DELETE /_security/api_key
  97. {
  98. "name" : "king-key-10"
  99. }
  100. DELETE /_security/api_key
  101. {
  102. "name" : "king-key-100"
  103. }
  104. DELETE /_security/api_key
  105. {
  106. "name" : "june-key-no-expire"
  107. }
  108. DELETE /_security/api_key
  109. {
  110. "name" : "june-key-10"
  111. }
  112. --------------------------------------------------
  113. // TEARDOWN
  114. ////
  115. Retrieves information for API keys with <<query-dsl,Query DSL>>
  116. in a <<paginate-search-results,paginated>> fashion.
  117. [[security-api-query-api-key-request]]
  118. ==== {api-request-title}
  119. `GET /_security/_query/api_key`
  120. `POST /_security/_query/api_key`
  121. [[security-api-query-api-key-prereqs]]
  122. ==== {api-prereq-title}
  123. * To use this API, you must have at least the `manage_own_api_key` or the `read_security`
  124. cluster privileges.
  125. * If you have only the `manage_own_api_key` privilege, this API returns only
  126. the API keys that you own. If you have the `read_security`, `manage_api_key` or greater
  127. privileges (including `manage_security`), this API returns all API keys
  128. regardless of ownership.
  129. [[security-api-query-api-key-desc]]
  130. ==== {api-description-title}
  131. Use this API to retrieve the API keys created with the
  132. <<security-api-create-api-key,create API key API>> in a paginated manner.
  133. You can optionally filter the results with a query.
  134. [[security-api-query-api-key-query-params]]
  135. ==== {api-path-parms-title}
  136. `with_limited_by`::
  137. (Optional, Boolean) A boolean flag to return the snapshot of the owner user's role descriptors
  138. associated with the API key. An API key's actual permission is the intersection of
  139. its <<api-key-role-descriptors,assigned role descriptors>> and the owner user's role descriptors
  140. (effectively limited by it). An API key cannot retrieve any API key's limited-by role descriptors
  141. (including itself) unless it has `manage_api_key` or higher privileges.
  142. [[security-api-query-api-key-request-body]]
  143. ==== {api-request-body-title}
  144. You can specify the following parameters in the request body:
  145. `query`::
  146. (Optional, object) A <<query-dsl,query>> to filter which API keys to return.
  147. If the query parameter is missing, it is equivalent to a `match_all` query.
  148. The query supports a subset of query types, including
  149. <<query-dsl-match-all-query,`match_all`>>, <<query-dsl-bool-query,`bool`>>,
  150. <<query-dsl-term-query,`term`>>, <<query-dsl-terms-query,`terms`>>,
  151. <<query-dsl-match-query,`match`>>, <<query-dsl-ids-query,`ids`>>,
  152. <<query-dsl-prefix-query,`prefix`>>, <<query-dsl-wildcard-query,`wildcard`>>,
  153. <<query-dsl-exists-query,`exists`>>, <<query-dsl-range-query,`range`>>,
  154. and <<query-dsl-simple-query-string-query,`simple query string`>>
  155. +
  156. You can query the following public values associated with an API key.
  157. +
  158. NOTE: The queryable string values associated with API keys are internally mapped as <<keyword,`keywords`>>.
  159. Consequently, if no <<analysis-analyzers,`analyzer`>> parameter is specified for a
  160. <<query-dsl-match-query,`match`>> query, then the provided match query string is interpreted as
  161. a single keyword value. Such a <<query-dsl-match-query,`match`>> query is hence equivalent to a
  162. <<query-dsl-term-query,`term`>> query.
  163. +
  164. .Valid values for `query`
  165. [%collapsible%open]
  166. ====
  167. `id`::
  168. ID of the API key. Note `id` must be queried with the <<query-dsl-ids-query,`ids`>> query.
  169. `type`::
  170. API keys can be of type `rest`, if created via the <<security-api-create-api-key, Create API key>> or
  171. the <<security-api-grant-api-key, Grant API key>> APIs, or of type `cross_cluster` if created via
  172. the <<security-api-create-cross-cluster-api-key, Create Cross-Cluster API key>> API.
  173. `name`::
  174. Name of the API key.
  175. `creation`::
  176. Creation time of the API key in milliseconds.
  177. `expiration`::
  178. Expiration time of the API key in milliseconds. This is `null` if the key was not configured to expire.
  179. `invalidated`::
  180. Indicates whether the API key is invalidated. If `true`, the key is invalidated.
  181. Defaults to `false`.
  182. `invalidation`::
  183. Invalidation time of the API key in milliseconds. This field is only set for invalidated API keys.
  184. `username`::
  185. Username of the API key owner.
  186. `realm`::
  187. Realm name of the API key owner.
  188. `metadata`::
  189. Metadata field associated with the API key, such as `metadata.my_field`.
  190. Metadata is internally indexed as a <<flattened,flattened>> field type.
  191. This means that all fields act like `keyword` fields when querying and sorting.
  192. It's not possible to refer to a subset of metadata fields using wildcard
  193. patterns, e.g. `metadata.field*`, even for query types that support field
  194. name patterns. Lastly, all the metadata fields can be searched together when
  195. simply mentioning `metadata` (not followed by any dot and sub-field name).
  196. NOTE: You cannot query the role descriptors of an API key.
  197. ====
  198. `aggs`::
  199. (Optional, object) Any <<search-aggregations,aggregations>> to run over the corpus of returned API keys.
  200. Aggregations and queries work together. Aggregations are computed only on the API keys that match the query.
  201. This supports only a subset of aggregation types, namely: <<search-aggregations-bucket-terms-aggregation,terms>>,
  202. <<search-aggregations-bucket-range-aggregation,range>>, <<search-aggregations-bucket-daterange-aggregation,date range>>,
  203. <<search-aggregations-bucket-missing-aggregation,missing>>, <<search-aggregations-metrics-cardinality-aggregation,cardinality>>,
  204. <<search-aggregations-metrics-valuecount-aggregation,value count>>, <<search-aggregations-bucket-composite-aggregation,composite>>,
  205. <<search-aggregations-bucket-filter-aggregation,filter>>, and <<search-aggregations-bucket-filters-aggregation,filters>>.
  206. Additionally, aggregations only run over the same subset of fields that `query` works with.
  207. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=from]
  208. +
  209. By default, you cannot page through more than 10,000 hits using the `from` and
  210. `size` parameters. To page through more hits, use the
  211. <<search-after,`search_after`>> parameter.
  212. `size`::
  213. (Optional, integer) The number of hits to return. Must not be negative and defaults to `10`.
  214. The `size` parameter can be set to `0`, in which case no API key matches are returned,
  215. only the aggregation results.
  216. +
  217. By default, you cannot page through more than 10,000 hits using the `from` and
  218. `size` parameters. To page through more hits, use the
  219. <<search-after,`search_after`>> parameter.
  220. `sort`::
  221. (Optional, object) <<sort-search-results,Sort definition>>. Other than `id`,
  222. all public fields of an API key are eligible for sorting. In addition, sort can
  223. also be applied to the `_doc` field to sort by index order.
  224. `search_after`::
  225. (Optional, array) <<search-after,Search after>> definition.
  226. [[security-api-query-api-key-response-body]]
  227. ==== {api-response-body-title}
  228. This API returns the following top level fields:
  229. `total`::
  230. The total number of API keys found.
  231. `count`::
  232. The number of API keys returned in the response.
  233. `api_keys`::
  234. A list of API key information.
  235. [[security-api-query-api-key-example]]
  236. ==== {api-examples-title}
  237. The following request lists all API keys, assuming you have the
  238. `manage_api_key` privilege:
  239. [source,console]
  240. ----
  241. GET /_security/_query/api_key
  242. ----
  243. A successful call returns a JSON structure that contains the information
  244. retrieved from one or more API keys:
  245. [source,js]
  246. ----
  247. {
  248. "total": 3,
  249. "count": 3,
  250. "api_keys": [ <1>
  251. {
  252. "id": "nkvrGXsB8w290t56q3Rg",
  253. "name": "my-api-key-1",
  254. "creation": 1628227480421,
  255. "expiration": 1629091480421,
  256. "invalidated": false,
  257. "username": "elastic",
  258. "realm": "reserved",
  259. "realm_type": "reserved",
  260. "metadata": {
  261. "letter": "a"
  262. },
  263. "role_descriptors": { <2>
  264. "role-a": {
  265. "cluster": [
  266. "monitor"
  267. ],
  268. "indices": [
  269. {
  270. "names": [
  271. "index-a"
  272. ],
  273. "privileges": [
  274. "read"
  275. ],
  276. "allow_restricted_indices": false
  277. }
  278. ],
  279. "applications": [ ],
  280. "run_as": [ ],
  281. "metadata": { },
  282. "transient_metadata": {
  283. "enabled": true
  284. }
  285. }
  286. }
  287. },
  288. {
  289. "id": "oEvrGXsB8w290t5683TI",
  290. "name": "my-api-key-2",
  291. "creation": 1628227498953,
  292. "expiration": 1628313898953,
  293. "invalidated": false,
  294. "username": "elastic",
  295. "realm": "reserved",
  296. "metadata": {
  297. "letter": "b"
  298. },
  299. "role_descriptors": { } <3>
  300. }
  301. ]
  302. }
  303. ----
  304. // NOTCONSOLE
  305. <1> The list of API keys that were retrieved for this request
  306. <2> The role descriptors that are assigned to this API key when it was <<api-key-role-descriptors,created>>
  307. or last <<security-api-update-api-key-api-key-role-descriptors,updated>>. Note the API key's
  308. effective permissions are an intersection of its assigned privileges and the point-in-time snapshot of
  309. the owner user's permissions.
  310. <3> An empty role descriptors means the API key inherits the owner user's permissions.
  311. If you create an API key with the following details:
  312. [source,console]
  313. ----
  314. POST /_security/api_key
  315. {
  316. "name": "application-key-1",
  317. "metadata": { "application": "my-application"}
  318. }
  319. ----
  320. A successful call returns a JSON structure that provides
  321. API key information. For example:
  322. [source,console-result]
  323. ----
  324. {
  325. "id": "VuaCfGcBCdbkQm-e5aOx",
  326. "name": "application-key-1",
  327. "api_key": "ui2lp2axTNmsyakw9tvNnw",
  328. "encoded": "VnVhQ2ZHY0JDZGJrUW0tZTVhT3g6dWkybHAyYXhUTm1zeWFrdzl0dk5udw=="
  329. }
  330. ----
  331. // TESTRESPONSE[s/VuaCfGcBCdbkQm-e5aOx/$body.id/]
  332. // TESTRESPONSE[s/ui2lp2axTNmsyakw9tvNnw/$body.api_key/]
  333. // TESTRESPONSE[s/VnVhQ2ZHY0JDZGJrUW0tZTVhT3g6dWkybHAyYXhUTm1zeWFrdzl0dk5udw==/$body.encoded/]
  334. Use the information from the response to retrieve the API key by ID:
  335. [source,console]
  336. ----
  337. GET /_security/_query/api_key?with_limited_by=true
  338. {
  339. "query": {
  340. "ids": {
  341. "values": [
  342. "VuaCfGcBCdbkQm-e5aOx"
  343. ]
  344. }
  345. }
  346. }
  347. ----
  348. // TEST[s/VuaCfGcBCdbkQm-e5aOx/$body.id/]
  349. // TEST[continued]
  350. A successful call returns a JSON structure for API key information including its limited-by role descriptors:
  351. [source,js]
  352. --------------------------------------------------
  353. {
  354. "api_keys": [
  355. {
  356. "id": "VuaCfGcBCdbkQm-e5aOx",
  357. "name": "application-key-1",
  358. "creation": 1548550550158,
  359. "expiration": 1548551550158,
  360. "invalidated": false,
  361. "username": "myuser",
  362. "realm": "native1",
  363. "realm_type": "native",
  364. "metadata": {
  365. "application": "my-application"
  366. },
  367. "role_descriptors": { },
  368. "limited_by": [ <1>
  369. {
  370. "role-power-user": {
  371. "cluster": [
  372. "monitor"
  373. ],
  374. "indices": [
  375. {
  376. "names": [
  377. "*"
  378. ],
  379. "privileges": [
  380. "read"
  381. ],
  382. "allow_restricted_indices": false
  383. }
  384. ],
  385. "applications": [ ],
  386. "run_as": [ ],
  387. "metadata": { },
  388. "transient_metadata": {
  389. "enabled": true
  390. }
  391. }
  392. }
  393. ]
  394. }
  395. ]
  396. }
  397. --------------------------------------------------
  398. // NOTCONSOLE
  399. <1> The owner user's permissions associated with the API key.
  400. It is a point-in-time snapshot captured at <<security-api-create-api-key,creation>> and
  401. subsequent <<security-api-update-api-key,updates>>. An API key's
  402. effective permissions are an intersection of its assigned privileges and
  403. the owner user's permissions.
  404. You can also retrieve the API key by name:
  405. [source,console]
  406. ----
  407. GET /_security/_query/api_key
  408. {
  409. "query": {
  410. "term": {
  411. "name": {
  412. "value": "application-key-1"
  413. }
  414. }
  415. }
  416. }
  417. ----
  418. // TEST[continued]
  419. Use a `bool` query to issue complex logical conditions and use
  420. `from`, `size`, `sort` to help paginate the result:
  421. [source,js]
  422. ----
  423. GET /_security/_query/api_key
  424. {
  425. "query": {
  426. "bool": {
  427. "must": [
  428. {
  429. "prefix": {
  430. "name": "app1-key-" <1>
  431. }
  432. },
  433. {
  434. "term": {
  435. "invalidated": "false" <2>
  436. }
  437. }
  438. ],
  439. "must_not": [
  440. {
  441. "term": {
  442. "name": "app1-key-01" <3>
  443. }
  444. }
  445. ],
  446. "filter": [
  447. {
  448. "wildcard": {
  449. "username": "org-*-user" <4>
  450. }
  451. },
  452. {
  453. "term": {
  454. "metadata.environment": "production" <5>
  455. }
  456. }
  457. ]
  458. }
  459. },
  460. "from": 20, <6>
  461. "size": 10, <7>
  462. "sort": [ <8>
  463. { "creation": { "order": "desc", "format": "date_time" } },
  464. "name"
  465. ]
  466. }
  467. ----
  468. // NOTCONSOLE
  469. <1> The API key name must begin with `app1-key-`
  470. <2> The API key must still be valid
  471. <3> The API key name must not be `app1-key-01`
  472. <4> The API key must be owned by a username of the <<query-dsl-wildcard-query,wildcard>> pattern `org-*-user`
  473. <5> The API key must have the metadata field `environment` that has the value of `production`
  474. <6> The offset to begin the search result is the 20th (zero-based index) API key
  475. <7> The page size of the response is 10 API keys
  476. <8> The result is first sorted by `creation` date in descending order, then by name in ascending order
  477. The response contains a list of matched API keys along with their sort values:
  478. [source,js]
  479. ----
  480. {
  481. "total": 100,
  482. "count": 10,
  483. "api_keys": [
  484. {
  485. "id": "CLXgVnsBOGkf8IyjcXU7",
  486. "name": "app1-key-79",
  487. "creation": 1629250154811,
  488. "invalidated": false,
  489. "username": "org-admin-user",
  490. "realm": "native1",
  491. "metadata": {
  492. "environment": "production"
  493. },
  494. "role_descriptors": { },
  495. "_sort": [
  496. "2021-08-18T01:29:14.811Z", <1>
  497. "app1-key-79" <2>
  498. ]
  499. },
  500. {
  501. "id": "BrXgVnsBOGkf8IyjbXVB",
  502. "name": "app1-key-78",
  503. "creation": 1629250153794,
  504. "invalidated": false,
  505. "username": "org-admin-user",
  506. "realm": "native1",
  507. "metadata": {
  508. "environment": "production"
  509. },
  510. "role_descriptors": { },
  511. "_sort": [
  512. "2021-08-18T01:29:13.794Z",
  513. "app1-key-78"
  514. ]
  515. },
  516. ...
  517. ]
  518. }
  519. ----
  520. // NOTCONSOLE
  521. <1> The first sort value is creation time, which is displayed in `date_time` <<mapping-date-format,format>> as defined in the request
  522. <2> The second sort value is the API key name
  523. [[security-api-query-api-key-with-aggs-example]]
  524. ==== Aggregations Example
  525. For example, given 2 users "june" and "king", each owning 3 API keys:
  526. * one that never expires (invalidated for user "king")
  527. * one that expires in 10 days
  528. * and one that expires in 100 day (invalidated for user "june")
  529. the following request returns the names of valid (not expired and not invalidated) API keys
  530. that expire soon (in 30 days time), grouped by owner username.
  531. ===== Request
  532. [source,console]
  533. ----
  534. POST /_security/_query/api_key
  535. {
  536. "size": 0,
  537. "query": {
  538. "bool": {
  539. "must": {
  540. "term": {
  541. "invalidated": false <1>
  542. }
  543. },
  544. "should": [ <2>
  545. {
  546. "range": { "expiration": { "gte": "now" } }
  547. },
  548. {
  549. "bool": { "must_not": { "exists": { "field": "expiration" } } }
  550. }
  551. ],
  552. "minimum_should_match": 1
  553. }
  554. },
  555. "aggs": {
  556. "keys_by_username": {
  557. "composite": {
  558. "sources": [ { "usernames": { "terms": { "field": "username" } } } ] <3>
  559. },
  560. "aggs": {
  561. "expires_soon": {
  562. "filter": {
  563. "range": { "expiration": { "lte": "now+30d/d" } } <4>
  564. },
  565. "aggs": {
  566. "key_names": { "terms": { "field": "name" } }
  567. }
  568. }
  569. }
  570. }
  571. }
  572. }
  573. ----
  574. <1> Matching API keys must not be invalidated
  575. <2> Matching API keys must be either not expired or not have an expiration date
  576. <3> Aggregate all matching keys (i.e. all valid keys) by their owner username
  577. <4> Further aggregate the per-username valid keys into a soon-to-expire bucket
  578. ===== Response
  579. [source,console-result]
  580. ----
  581. {
  582. "total" : 4, <1>
  583. "count" : 0,
  584. "api_keys" : [ ],
  585. "aggregations" : {
  586. "keys_by_username" : {
  587. "after_key" : {
  588. "usernames" : "king"
  589. },
  590. "buckets" : [
  591. {
  592. "key" : {
  593. "usernames" : "june"
  594. },
  595. "doc_count" : 2, <2>
  596. "expires_soon" : {
  597. "doc_count" : 1,
  598. "key_names" : {
  599. "doc_count_error_upper_bound" : 0,
  600. "sum_other_doc_count" : 0,
  601. "buckets" : [
  602. {
  603. "key" : "june-key-10",
  604. "doc_count" : 1
  605. }
  606. ]
  607. }
  608. }
  609. },
  610. {
  611. "key" : {
  612. "usernames" : "king"
  613. },
  614. "doc_count" : 2,
  615. "expires_soon" : {
  616. "doc_count" : 1, <3>
  617. "key_names" : {
  618. "doc_count_error_upper_bound" : 0,
  619. "sum_other_doc_count" : 0,
  620. "buckets" : [ <4>
  621. {
  622. "key" : "king-key-10",
  623. "doc_count" : 1
  624. }
  625. ]
  626. }
  627. }
  628. }
  629. ]
  630. }
  631. }
  632. }
  633. ----
  634. <1> Total number of valid API keys (2 for each user)
  635. <2> Number of valid API keys for user "june"
  636. <3> Number of valid API keys expiring soon for user "king"
  637. <4> The names of soon-to-expire API keys for user "king"
  638. To retrieve the invalidated (but not yet deleted) API keys,
  639. grouped by owner username and API key name, issue the following request:
  640. ===== Request
  641. [source,console]
  642. ----
  643. POST /_security/_query/api_key
  644. {
  645. "size": 0,
  646. "query": {
  647. "bool": {
  648. "filter": {
  649. "term": {
  650. "invalidated": true
  651. }
  652. }
  653. }
  654. },
  655. "aggs": {
  656. "invalidated_keys": {
  657. "composite": {
  658. "sources": [
  659. { "username": { "terms": { "field": "username" } } },
  660. { "key_name": { "terms": { "field": "name" } } }
  661. ]
  662. }
  663. }
  664. }
  665. }
  666. ----
  667. ===== Response
  668. [source,console-result]
  669. ----
  670. {
  671. "total" : 2,
  672. "count" : 0,
  673. "api_keys" : [ ],
  674. "aggregations" : {
  675. "invalidated_keys" : {
  676. "after_key" : {
  677. "username" : "king",
  678. "key_name" : "king-key-no-expire"
  679. },
  680. "buckets" : [
  681. {
  682. "key" : {
  683. "username" : "june",
  684. "key_name" : "june-key-100"
  685. },
  686. "doc_count" : 1
  687. },
  688. {
  689. "key" : {
  690. "username" : "king",
  691. "key_name" : "king-key-no-expire"
  692. },
  693. "doc_count" : 1
  694. }
  695. ]
  696. }
  697. }
  698. }
  699. ----