Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct the documentation for create_doc privilege #47784

Merged
merged 11 commits into from
Nov 19, 2019
3 changes: 2 additions & 1 deletion docs/reference/docs/index_.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ include::{docdir}/rest-api/common-parms.asciidoc[tag=if_primary_term]
(Optional, enum) Set to `create` to only index the document
if it does not already exist (_put if absent_). If a document with the specified
`_id` already exists, the indexing operation will fail. Same as using the
`<index>/_create` endpoint. Valid values: `index`, `create`. Default: `index`.
`<index>/_create` endpoint. Valid values: `index`, `create`.
If document id is specified, it defaults to `index` or else it defaults to `create`.
bizybot marked this conversation as resolved.
Show resolved Hide resolved

include::{docdir}/rest-api/common-parms.asciidoc[tag=pipeline]

Expand Down
15 changes: 11 additions & 4 deletions x-pack/docs/en/security/authorization/privileges.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,17 @@ Privilege to index documents. Also grants access to the update mapping action.
However, it does not enable a user to update existing documents.
+
--
NOTE: When indexing documents with an external `_id` either via the index API or
the bulk API, the request must use `op_type` as `create`. If `_id`s are
generated automatically, the authorization happens as if the `op_type` is set to
`create`.
[NOTE]
====
This privilege relies on the `op_type` of indexing requests (<<docs-index_>> and
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This privilege relies on....

It seems to me that the implication here is that when you have only create_doc privilege, you cannot use the index or bulk APIs successfully unless you use one of the three options below. If that's true, I don't think we're making that dependency clear enough. I'd suggest changing "the op_type can be set to create..." to something like "...you must set the op_type to create..."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you index a document (with no '_id'), then the 'op_type' is set to 'create' internally. I think the implication is correct here but open for other suggestions. Thank you.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps something more like you must ensure that the op_type is set to create ?

<<docs-bulk>>). When ingesting documents as a user who has the `create_doc`
privilege (and no higher privilege such as `index` or `write`), the `op_type`
can be set to `create` through one of the following:

* Explicitly setting the `op_type` in the index or bulk APIs
* Using the `_create` endpoint for the index API
* Creating a document with an auto-generated `_id`
====

--

Expand Down