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

HTTP Methods Examples Provided 20231026 #6756

Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
43d9d6b
updating the doucumentation to be more descriptive and adding example…
leanneeliatra Mar 21, 2024
9715d39
Merge branch 'main' into 20231026-index-document-method-type-examples
leanneeliatra Mar 22, 2024
1172fff
actual runnable examples given to the user for greater clarity
leanneeliatra Mar 22, 2024
42be225
Merge branch 'main' into 20231026-index-document-method-type-examples
leanneeliatra Mar 22, 2024
107358e
removing duplication added in error and addressing review comments
leanneeliatra Mar 27, 2024
de1ef92
adding back the first 2 sections
leanneeliatra Mar 27, 2024
3bf6467
fixing formatting
leanneeliatra Mar 27, 2024
3734e5c
Merge branch 'main' into 20231026-index-document-method-type-examples
leanneeliatra Mar 27, 2024
47f995d
Merge branch 'main' into 20231026-index-document-method-type-examples
leanneeliatra Mar 28, 2024
eb2fb7d
Merge branch 'main' into 20231026-index-document-method-type-examples
leanneeliatra Mar 28, 2024
368f99b
Merge branch 'main' into 20231026-index-document-method-type-examples
leanneeliatra Mar 28, 2024
17408cd
Apply suggestions from code review
leanneeliatra Mar 29, 2024
3bab898
Merge branch 'main' into 20231026-index-document-method-type-examples
leanneeliatra Mar 29, 2024
871c74b
updated introduction scentance
leanneeliatra Mar 29, 2024
3fc8d04
Update _api-reference/document-apis/index-document.md
Naarcha-AWS Mar 29, 2024
8a21556
Update index-document.md
leanneeliatra Apr 2, 2024
ed6a425
Merge branch 'main' into 20231026-index-document-method-type-examples
leanneeliatra Apr 2, 2024
410ff13
Merge branch 'main' into 20231026-index-document-method-type-examples
leanneeliatra Apr 4, 2024
ca262ff
Apply suggestions from code review
leanneeliatra Apr 4, 2024
733c177
addressing review comments and editorial review
leanneeliatra Apr 4, 2024
17162a9
Update _security/access-control/document-level-security.md
leanneeliatra Apr 5, 2024
feb2735
Update _security/access-control/document-level-security.md
leanneeliatra Apr 5, 2024
7e430b2
Apply suggestions from code review
leanneeliatra Apr 5, 2024
e8f2bbe
Merge branch 'main' into 20231026-index-document-method-type-examples
leanneeliatra Apr 5, 2024
b37c910
Merge branch 'main' into 20231026-index-document-method-type-examples
Naarcha-AWS Apr 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 48 additions & 1 deletion _api-reference/document-apis/index-document.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ redirect_from:
**Introduced 1.0**
{: .label .label-purple}

Before you can search for data, you must first add documents. This operation adds a single document to your index.
You can use the `Index document` operation to add a single document to your index.

## Example

Expand All @@ -33,6 +33,53 @@ PUT <index>/_create/<_id>
POST <index>/_create/<_id>
```

- PUT adds or updates documents in the index with a specified ID. Used for controlled document creation or updates.
- POST adds documents with auto-generated IDs to the index. Useful for adding new documents without specifying IDs.
- `_create` is a type identifier indicating that document creation should only occur if the document with the specified ID doesn't already exist.
- `<index>` represents the name of the index to which the document will be added.
- `<_id>` represents the unique identifier of the document.

## Adding a sample index

Sample data can be added to the index with curl commands in the terminal, or through the API.
leanneeliatra marked this conversation as resolved.
Show resolved Hide resolved

To test the Document APIs, add a document by following the steps:
leanneeliatra marked this conversation as resolved.
Show resolved Hide resolved
leanneeliatra marked this conversation as resolved.
Show resolved Hide resolved
1. Open OpenSearch Dashboards.
2. Navigate to the actions menu.
3. In the **Management** section, choose **Dev Tools**.
4. Enter a command, and then select the green triangle play button to send the request. The following are some example commands.

### Create a sample-index
```json
PUT /sample-index
```
{% include copy-curl.html %}

### Example PUT request

```json
PUT /sample_index/_doc/1
{
"name": "Example",
"price": 29.99,
"description": "To be or not to be, that is the question"
}
```
{% include copy-curl.html %}

### Example POST request

```json
POST /sample_index/_doc
{
"name": "Another Example",
"price": 19.99,
"description": "We are such stuff as dreams are made on"
}

```
{% include copy-curl.html %}

## URL parameters

In your request, you must specify the index you want to add your document to. If the index doesn't already exist, OpenSearch automatically creates the index and adds in your document. All other URL parameters are optional.
Expand Down
54 changes: 27 additions & 27 deletions _security/access-control/document-level-security.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,35 @@ title: Document-level security
parent: Access control
nav_order: 85
redirect_from:
- /security/access-control/document-level-security/
- /security-plugin/access-control/document-level-security/
- /security/access-control/document-level-security/
- /security-plugin/access-control/document-level-security/
---

# Document-level security (DLS)

Document-level security lets you restrict a role to a subset of documents in an index.
For more information about OpenSearch users and roles, see the [documentation](https://opensearch.org/docs/latest/security/access-control/users-roles/#create-roles).

Use the following steps to get started with document-level and field-level security:
1. Open OpenSearch Dashboards.
2. Choose **Security** > **Roles**.
3. Select **Create Role** and provide a name for the role.
4. Review the **Index permissions** section and any necessary [index permissions](https://opensearch.org/docs/latest/security/access-control/permissions/) for the role.
5. Add document-level security, with the addition of a domain-specific language (DSL) query in the `Document level security - optional` section. A typical request sent to the `_search` API includes `{ "query": { ... } }` around the query, but with document-level security in OpenSearch Dashboards, you only need to specify the query itself. For example, the following DSL query specifies that for the new role to have access to a document, the query's `genres` field must include `Comedy`:

```json
{
"bool": {
"must": {
"match": {
"genres": "Comedy"
}
}
}
}
```

- ![Document- and field-level security screen in OpenSearch Dashboards]({{site.url}}{{site.baseurl}}/images/security-dls.png)
# Document-level security
Document-level security (DLS) lets you restrict a role to a subset of documents in an index. The easiest way to get started with document- and field-level security is to open OpenSearch Dashboards and choose **Security**. Then choose **Roles**, create a new role, and review the **Index Permissions** section. See the Index Permissions section in OpenSearch Dashboards in the following image.
leanneeliatra marked this conversation as resolved.
Show resolved Hide resolved

![Document- and field-level security screen in OpenSearch Dashboards]({{site.url}}{{site.baseurl}}/images/security-dls.png)
leanneeliatra marked this conversation as resolved.
Show resolved Hide resolved
leanneeliatra marked this conversation as resolved.
Show resolved Hide resolved


## Simple roles

Document-level security uses OpenSearch query DSL to define which documents a role grants access to. In OpenSearch Dashboards, choose an index pattern and provide a query in the **Document-level security** section:
leanneeliatra marked this conversation as resolved.
Show resolved Hide resolved

```json
{
"bool": {
"must": {
"match": {
"genres": "Comedy"
}
}
}
}
```

This query specifies that for the role to have access to a document, its `genres` field must include `Comedy`.

A typical request to the `_search` API includes `{ "query": { ... } }` around the query, but in this case, you only need to specify the query itself.
leanneeliatra marked this conversation as resolved.
Show resolved Hide resolved

## Updating roles by accessing the REST API

Expand Down
Loading