Index and OpenSearch TOC changes (#2946)

* Add new Query DSL section

Signed-off-by: Naarcha-AWS <naarcha@amazon.com>

* Change config settings

Signed-off-by: Naarcha-AWS <naarcha@amazon.com>

* Fix links

Signed-off-by: Naarcha-AWS <naarcha@amazon.com>

* Add Query DSL back to Search

Signed-off-by: Naarcha-AWS <naarcha@amazon.com>

* Fix remaining links

Signed-off-by: Naarcha-AWS <naarcha@amazon.com>

* Last reorder

Signed-off-by: Naarcha-AWS <naarcha@amazon.com>

* Add Heather's feedback

Signed-off-by: Naarcha-AWS <naarcha@amazon.com>

* Add Query DSL section. Delete Index Data page

Signed-off-by: Naarcha-AWS <naarcha@amazon.com>

* Fix index title

Signed-off-by: Naarcha-AWS <naarcha@amazon.com>

* Add correct title to managing indexes

Signed-off-by: Naarcha-AWS <naarcha@amazon.com>

* Change config yml

Signed-off-by: Naarcha-AWS <naarcha@amazon.com>

* Add permalinks for each page in query DSL section

Signed-off-by: Naarcha-AWS <naarcha@amazon.com>

* :wq

---------

Signed-off-by: Naarcha-AWS <naarcha@amazon.com>
This commit is contained in:
Naarcha-AWS 2023-03-08 09:53:21 -06:00 committed by GitHub
parent 547fe605db
commit e119a93798
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
83 changed files with 484 additions and 489 deletions

View File

@ -2,6 +2,8 @@
layout: default
title: Common REST Parameters
nav_order: 93
redirect_from:
- /opensearch/common-parameters/
---
# Common REST parameters

View File

@ -2,6 +2,8 @@
layout: default
title: Popular APIs
nav_order: 96
redirect_from:
- /opensearch/popular-api/
---
# Popular APIs

View File

@ -2,6 +2,8 @@
layout: default
title: Supported units
nav_order: 90
redirect_from:
- /opensearch/units/
---
# Supported units

View File

@ -34,9 +34,6 @@ collections:
upgrade-to:
permalink: /:collection/:path/
output: true
opensearch:
permalink: /:collection/:path/
output: true
im-plugin:
permalink: /:collection/:path/
output: true
@ -54,13 +51,10 @@ collections:
output: true
search-plugins:
permalink: /:collection/:path/
output: true
output: true
ml-commons-plugin:
permalink: /:collection/:path/
output: true
neural-search-plugin:
permalink: /:collection/:path/
output: true
output: true
tuning-your-cluster:
permalink: /:collection/:path/
output: true
@ -70,10 +64,10 @@ collections:
observing-your-data:
permalink: /:collection/:path/
output: true
ml-commons-plugin:
query-dsl:
permalink: /:collection/:path/
output: true
neural-search-plugin:
output: true
field-types:
permalink: /:collection/:path/
output: true
clients:
@ -106,9 +100,6 @@ just_the_docs:
# nav_exclude: true
nav_fold: true
# search_exclude: true
opensearch:
name: OpenSearch
nav_fold: true
im-plugin:
name: Managing Indexes
nav_fold: true
@ -122,7 +113,7 @@ just_the_docs:
name: Security in OpenSearch
nav_fold: true
security-analytics:
name: Security analytics plugin
name: Security analytics
nav_fold: true
search-plugins:
name: Search
@ -130,9 +121,6 @@ just_the_docs:
ml-commons-plugin:
name: Machine learning
nav_fold: true
neural-search-plugin:
name: Neural Search
nav_fold: true
tuning-your-cluster:
name: Tuning your cluster
nav_fold: true
@ -142,6 +130,12 @@ just_the_docs:
observing-your-data:
name: Observability
nav_fold: true
query-dsl:
name: Query DSL, Aggregations, and Analyzers
nav_fold: true
field-types:
name: Mappings and field types
nav_fold: true
clients:
name: Clients
nav_fold: true
@ -157,8 +151,6 @@ just_the_docs:
troubleshoot:
name: Troubleshooting
nav_fold: true
external_links:
name: External links
# Enable or disable the site search

View File

@ -5,6 +5,7 @@ parent: Index management in Dashboards
nav_order: 20
redirect_from:
- /dashboards/admin-ui-index/datastream/
- /opensearch/data-streams/
---
# Data streams

View File

@ -11,7 +11,7 @@ redirect_from:
Introduced 2.6
{: .label .label-purple }
OpenSearch Dashboards allows you to perform a [force merge]({{site.url}}{{site.baseurl}}/im-plugin/ism/error-prevention/index/#force_merge) operation on two or more indexes with **Index Management**.
OpenSearch Dashboards allows you to perform a [force merge]({{site.url}}{{site.baseurl}}/im-plugin/ism/error-prevention/index#force_merge) operation on two or more indexes with **Index Management**.
## Force merging indexes

View File

@ -1,7 +0,0 @@
---
layout: default
title: Dashboards developer guide
nav_order: 2
permalink: /dashboards-developer-guide/
redirect_to: https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/DEVELOPER_GUIDE.md
---

View File

@ -1,7 +0,0 @@
---
layout: default
title: Javadoc
nav_order: 1
permalink: /javadoc/
redirect_to: https://opensearch.org/javadocs/
---

View File

@ -1,6 +0,0 @@
---
layout: default
nav_exclude: true
permalink: /javadocs/
redirect_to: https://opensearch.org/javadocs/
---

View File

@ -4,6 +4,8 @@ title: Alias
nav_order: 10
has_children: false
parent: Supported field types
redirect_from:
- /opensearch/supported-field-types/alias/
---
# Alias field type

View File

@ -5,6 +5,8 @@ nav_order: 50
has_children: true
has_toc: false
parent: Supported field types
redirect_from:
- /opensearch/supported-field-types/autocomplete/
---
# Autocomplete field types

View File

@ -4,6 +4,8 @@ title: Binary
parent: Supported field types
nav_order: 12
has_children: false
redirect_from:
- /opensearch/supported-field-types/binary/
---
# Binary field type

View File

@ -4,6 +4,8 @@ title: Boolean
nav_order: 20
has_children: false
parent: Supported field types
redirect_from:
- /opensearch/supported-field-types/boolean/
---
# Boolean field type

View File

@ -5,6 +5,8 @@ nav_order: 51
has_children: false
parent: Autocomplete field types
grand_parent: Supported field types
redirect_from:
- /opensearch/supported-field-types/completion/
---
# Completion field type

View File

@ -4,6 +4,8 @@ title: Date
nav_order: 25
has_children: false
parent: Supported field types
redirect_from:
- /opensearch/supported-field-types/date/
---
# Date field type

View File

@ -5,6 +5,8 @@ nav_order: 56
has_children: false
parent: Geographic field types
grand_parent: Supported field types
redirect_from:
- /opensearch/supported-field-types/geo-point/
---
# Geopoint field type

View File

@ -5,6 +5,8 @@ nav_order: 57
has_children: false
parent: Geographic field types
grand_parent: Supported field types
redirect_from:
- /opensearch/supported-field-types/geo-shape/
---
# Geoshape field type

View File

@ -5,6 +5,8 @@ nav_order: 55
has_children: true
has_toc: false
parent: Supported field types
redirect_from:
- /opensearch/supported-field-types/geographic/
---
# Geographic field types

View File

@ -6,6 +6,7 @@ has_children: true
has_toc: false
redirect_from:
- /opensearch/supported-field-types/
- //opensearch/supported-field-types/index/
---
# Supported field types

View File

@ -4,6 +4,8 @@ title: IP address
nav_order: 30
has_children: false
parent: Supported field types
redirect_from:
- /opensearch/supported-field-types/ip/
---
# IP address field type

View File

@ -5,6 +5,8 @@ nav_order: 43
has_children: false
parent: Object field types
grand_parent: Supported field types
redirect_from:
- /opensearch/supported-field-types/join/
---
# Join field type

View File

@ -5,6 +5,8 @@ nav_order: 46
has_children: false
parent: String field types
grand_parent: Supported field types
redirect_from:
- /opensearch/supported-field-types/keyword/
---
# Keyword field type

View File

@ -2,6 +2,8 @@
layout: default
title: Mapping
nav_order: 13
redirect_from:
- /opensearch/mappings/
---
# Mapping

View File

@ -5,6 +5,8 @@ nav_order: 42
has_children: false
parent: Object field types
grand_parent: Supported field types
redirect_from:
- /opensearch/supported-field-types/nested/
---
# Nested field type

View File

@ -4,6 +4,8 @@ title: Numeric field types
parent: Supported field types
nav_order: 15
has_children: false
redirect_from:
- /opensearch/supported-field-types/numeric/
---
# Numeric field types

View File

@ -5,6 +5,8 @@ nav_order: 41
has_children: false
parent: Object field types
grand_parent: Supported field types
redirect_from:
- /opensearch/supported-field-types/object/
---
# Object field type

View File

@ -4,6 +4,8 @@ title: Percolator
nav_order: 65
has_children: false
parent: Supported field types
redirect_from:
- /opensearch/supported-field-types/percolator/
---
# Percolator field type

View File

@ -4,6 +4,8 @@ title: Range field types
nav_order: 35
has_children: false
parent: Supported field types
redirect_from:
- /opensearch/supported-field-types/range/
---
# Range field types

View File

@ -4,6 +4,8 @@ title: Rank field types
nav_order: 60
has_children: false
parent: Supported field types
redirect_from:
- /opensearch/supported-field-types/rank/
---
# Rank field types

View File

@ -5,6 +5,8 @@ nav_order: 53
has_children: false
parent: Autocomplete field types
grand_parent: Supported field types
redirect_from:
- /opensearch/supported-field-types/search-as-you-type/
---
# Search-as-you-type field type

View File

@ -5,6 +5,8 @@ nav_order: 45
has_children: true
has_toc: false
parent: Supported field types
redirect_from:
- /opensearch/supported-field-types/string/
---
# String field types

View File

@ -5,6 +5,8 @@ nav_order: 47
has_children: false
parent: String field types
grand_parent: Supported field types
redirect_from:
- /opensearch/supported-field-types/text/
---
# Text field type

View File

@ -5,6 +5,8 @@ nav_order: 48
has_children: false
parent: String field types
grand_parent: Supported field types
redirect_from:
- /opensearch/supported-field-types/token-count/
---
# Token count field type

View File

@ -5,6 +5,8 @@ nav_order: 58
has_children: false
parent: Cartesian field types
grand_parent: Supported field types
redirect_from:
- /opensearch/supported-field-types/xy-point/
---
# xy point field type

View File

@ -5,6 +5,8 @@ nav_order: 59
has_children: false
parent: Cartesian field types
grand_parent: Supported field types
redirect_from:
- /opensearch/supported-field-types/xy-shape/
---
# xy shape field type

View File

@ -5,6 +5,8 @@ nav_order: 57
has_children: true
has_toc: false
parent: Supported field types
redirect_from:
- /opensearch/supported-field-types/xy/
---
# Cartesian field types

View File

@ -1,7 +1,9 @@
---
layout: default
title: Index aliases
nav_order: 12
nav_order: 11
redirect_from:
- /opensearch/index-alias/
---
# Index aliases

View File

@ -3,8 +3,8 @@ layout: default
title: Index rollups
nav_order: 35
has_children: true
redirect_from: /im-plugin/index-rollups/
has_toc: false
redirect_from:
- /im-plugin/index-rollups/
---
# Index rollups

View File

@ -1,7 +1,9 @@
---
layout: default
title: Index templates
nav_order: 15
nav_order: 6
redirect_from:
- /opensearch/index-templates/
---
# Index templates

View File

@ -1,14 +1,285 @@
---
layout: default
title: About Index Management
title: Managing indexes
nav_order: 1
has_children: false
redirect_from:
- /im-plugin/
- /opensearch/index-data/
---
# About Index Management
# Managing indexes
OpenSearch Dashboards
{: .label .label-yellow :}
The Index Management (IM) plugin lets you automate recurring index management activities and reduce storage costs.
You index data using the OpenSearch REST API. Two APIs exist: the index API and the `_bulk` API.
For situations in which new data arrives incrementally (for example, customer orders from a small business), you might use the index API to add documents individually as they arrive. For situations in which the flow of data is less frequent (for example, weekly updates to a marketing website), you might prefer to generate a file and send it to the `_bulk` API. For large numbers of documents, lumping requests together and using the `_bulk` API offers superior performance. If your documents are enormous, however, you might need to index them individually.
## Introduction to indexing
Before you can search data, you must *index* it. Indexing is the method by which search engines organize data for fast retrieval. The resulting structure is called, fittingly, an index.
In OpenSearch, the basic unit of data is a JSON *document*. Within an index, OpenSearch identifies each document using a unique ID.
A request to the index API looks like this:
```json
PUT <index>/_doc/<id>
{ "A JSON": "document" }
```
A request to the `_bulk` API looks a little different, because you specify the index and ID in the bulk data:
```json
POST _bulk
{ "index": { "_index": "<index>", "_id": "<id>" } }
{ "A JSON": "document" }
```
Bulk data must conform to a specific format, which requires a newline character (`\n`) at the end of every line, including the last line. This is the basic format:
```
Action and metadata\n
Optional document\n
Action and metadata\n
Optional document\n
```
The document is optional, because `delete` actions don't require a document. The other actions (`index`, `create`, and `update`) all require a document. If you specifically want the action to fail if the document already exists, use the `create` action instead of the `index` action.
{: .note }
To index bulk data using the `curl` command, navigate to the folder where you have your file saved and run the following command:
```json
curl -H "Content-Type: application/x-ndjson" -POST https://localhost:9200/data/_bulk -u 'admin:admin' --insecure --data-binary "@data.json"
```
If any one of the actions in the `_bulk` API fail, OpenSearch continues to execute the other actions. Examine the `items` array in the response to figure out what went wrong. The entries in the `items` array are in the same order as the actions specified in the request.
OpenSearch automatically creates an index when you add a document to an index that doesn't already exist. It also automatically generates an ID if you don't specify an ID in the request. This simple example automatically creates the movies index, indexes the document, and assigns it a unique ID:
```json
POST movies/_doc
{ "title": "Spirited Away" }
```
Automatic ID generation has a clear downside: because the indexing request didn't specify a document ID, you can't easily update the document at a later time. Also, if you run this request 10 times, OpenSearch indexes this document as 10 different documents with unique IDs. To specify an ID of 1, use the following request (note the use of PUT instead of POST):
```json
PUT movies/_doc/1
{ "title": "Spirited Away" }
```
Because you must specify an ID, if you run this command 10 times, you still have just one document indexed with the `_version` field incremented to 10.
Indexes default to one primary shard and one replica. If you want to specify non-default settings, create the index before adding documents:
```json
PUT more-movies
{ "settings": { "number_of_shards": 6, "number_of_replicas": 2 } }
```
## Naming restrictions for indexes
OpenSearch indexes have the following naming restrictions:
- All letters must be lowercase.
- Index names can't begin with underscores (`_`) or hyphens (`-`).
- Index names can't contain spaces, commas, or the following characters:
`:`, `"`, `*`, `+`, `/`, `\`, `|`, `?`, `#`, `>`, or `<`
## Read data
After you index a document, you can retrieve it by sending a GET request to the same endpoint that you used for indexing:
```json
GET movies/_doc/1
{
"_index" : "movies",
"_type" : "_doc",
"_id" : "1",
"_version" : 1,
"_seq_no" : 0,
"_primary_term" : 1,
"found" : true,
"_source" : {
"title" : "Spirited Away"
}
}
```
You can see the document in the `_source` object. If the document is not found, the `found` key is `false` and the `_source` object is not part of the response.
To retrieve multiple documents with a single command, use the `_mget` operation.
The format for retrieving multiple documents is similar to the `_bulk` operation, where you must specify the index and ID in the request body:
```json
GET _mget
{
"docs": [
{
"_index": "<index>",
"_id": "<id>"
},
{
"_index": "<index>",
"_id": "<id>"
}
]
}
```
To only return specific fields in a document:
```json
GET _mget
{
"docs": [
{
"_index": "<index>",
"_id": "<id>",
"_source": "field1"
},
{
"_index": "<index>",
"_id": "<id>",
"_source": "field2"
}
]
}
```
To check if a document exists:
```json
HEAD movies/_doc/<doc-id>
```
If the document exists, you get back a `200 OK` response, and if it doesn't, you get back a `404 - Not Found` error.
## Update data
To update existing fields or to add new fields, send a POST request to the `_update` operation with your changes in a `doc` object:
```json
POST movies/_update/1
{
"doc": {
"title": "Castle in the Sky",
"genre": ["Animation", "Fantasy"]
}
}
```
Note the updated `title` field and new `genre` field:
```json
GET movies/_doc/1
{
"_index" : "movies",
"_type" : "_doc",
"_id" : "1",
"_version" : 2,
"_seq_no" : 1,
"_primary_term" : 1,
"found" : true,
"_source" : {
"title" : "Castle in the Sky",
"genre" : [
"Animation",
"Fantasy"
]
}
}
```
The document also has an incremented `_version` field. Use this field to keep track of how many times a document is updated.
POST requests make partial updates to documents. To altogether replace a document, use a PUT request:
```json
PUT movies/_doc/1
{
"title": "Spirited Away"
}
```
The document with ID of 1 will contain only the `title` field, because the entire document will be replaced with the document indexed in this PUT request.
Use the `upsert` object to conditionally update documents based on whether they already exist. Here, if the document exists, its `title` field changes to `Castle in the Sky`. If it doesn't, OpenSearch indexes the document in the `upsert` object.
```json
POST movies/_update/2
{
"doc": {
"title": "Castle in the Sky"
},
"upsert": {
"title": "Only Yesterday",
"genre": ["Animation", "Fantasy"],
"date": 1993
}
}
```
### Example response
```json
{
"_index" : "movies",
"_type" : "_doc",
"_id" : "2",
"_version" : 2,
"result" : "updated",
"_shards" : {
"total" : 2,
"successful" : 1,
"failed" : 0
},
"_seq_no" : 3,
"_primary_term" : 1
}
```
Each update operation for a document has a unique combination of the `_seq_no` and `_primary_term` values.
OpenSearch first writes your updates to the primary shard and then sends this change to all the replica shards. An uncommon issue can occur if multiple users of your OpenSearch-based application make updates to existing documents in the same index. In this situation, another user can read and update a document from a replica before it receives your update from the primary shard. Your update operation then ends up updating an older version of the document. In the best case, you and the other user make the same changes, and the document remains accurate. In the worst case, the document now contains out-of-date information.
To prevent this situation, use the `_seq_no` and `_primary_term` values in the request header:
```json
POST movies/_update/2?if_seq_no=3&if_primary_term=1
{
"doc": {
"title": "Castle in the Sky",
"genre": ["Animation", "Fantasy"]
}
}
```
If the document is updated after we retrieved it, the `_seq_no` and `_primary_term` values are different and our update operation fails with a `409 — Conflict` error.
When using the `_bulk` API, specify the `_seq_no` and `_primary_term` values within the action metadata.
## Delete data
To delete a document from an index, use a DELETE request:
```json
DELETE movies/_doc/1
```
The DELETE operation increments the `_version` field. If you add the document back to the same ID, the `_version` field increments again. This behavior occurs because OpenSearch deletes the document `_source`, but retains its metadata.
## Next steps
- The Index Management (IM) plugin lets you automate recurring index management activities and reduce storage costs. For more information, see [Index State Management]({{site.url}}{{site.baseurl}}/im-plugin/ism/index).
- For instructions on how to reindex data, see [Reindex data]({{site.url}}{{site.baseurl}}/im-plugin/reindex-data/).

View File

@ -1,11 +1,12 @@
---
layout: default
title: ISM Error Prevention
nav_order: 1
nav_order: 90
has_children: true
has_toc: false
redirect_from:
- /im-plugin/ism/error-prevention/
- /im-plugin/ism/error-prevention/index/
---
# ISM error prevention

View File

@ -1,7 +1,7 @@
---
layout: default
title: Index State Management
nav_order: 3
nav_order: 16
has_children: true
redirect_from:
- /im-plugin/ism/

View File

@ -1,7 +1,9 @@
---
layout: default
title: Reindex data
nav_order: 16
nav_order: 15
redirect_from:
- /opensearch/reindex-data/
---
# Reindex data

View File

@ -1,271 +0,0 @@
---
layout: default
title: Index data
nav_order: 10
---
# Index data
You index data using the OpenSearch REST API. Two APIs exist: the index API and the `_bulk` API.
For situations in which new data arrives incrementally (for example, customer orders from a small business), you might use the index API to add documents individually as they arrive. For situations in which the flow of data is less frequent (for example, weekly updates to a marketing website), you might prefer to generate a file and send it to the `_bulk` API. For large numbers of documents, lumping requests together and using the `_bulk` API offers superior performance. If your documents are enormous, however, you might need to index them individually.
## Introduction to indexing
Before you can search data, you must *index* it. Indexing is the method by which search engines organize data for fast retrieval. The resulting structure is called, fittingly, an index.
In OpenSearch, the basic unit of data is a JSON *document*. Within an index, OpenSearch identifies each document using a unique ID.
A request to the index API looks like this:
```json
PUT <index>/_doc/<id>
{ "A JSON": "document" }
```
A request to the `_bulk` API looks a little different, because you specify the index and ID in the bulk data:
```json
POST _bulk
{ "index": { "_index": "<index>", "_id": "<id>" } }
{ "A JSON": "document" }
```
Bulk data must conform to a specific format, which requires a newline character (`\n`) at the end of every line, including the last line. This is the basic format:
```
Action and metadata\n
Optional document\n
Action and metadata\n
Optional document\n
```
The document is optional, because `delete` actions don't require a document. The other actions (`index`, `create`, and `update`) all require a document. If you specifically want the action to fail if the document already exists, use the `create` action instead of the `index` action.
{: .note }
To index bulk data using the `curl` command, navigate to the folder where you have your file saved and run the following command:
```json
curl -H "Content-Type: application/x-ndjson" -POST https://localhost:9200/data/_bulk -u 'admin:admin' --insecure --data-binary "@data.json"
```
If any one of the actions in the `_bulk` API fail, OpenSearch continues to execute the other actions. Examine the `items` array in the response to figure out what went wrong. The entries in the `items` array are in the same order as the actions specified in the request.
OpenSearch automatically creates an index when you add a document to an index that doesn't already exist. It also automatically generates an ID if you don't specify an ID in the request. This simple example automatically creates the movies index, indexes the document, and assigns it a unique ID:
```json
POST movies/_doc
{ "title": "Spirited Away" }
```
Automatic ID generation has a clear downside: because the indexing request didn't specify a document ID, you can't easily update the document at a later time. Also, if you run this request 10 times, OpenSearch indexes this document as 10 different documents with unique IDs. To specify an ID of 1, use the following request (note the use of PUT instead of POST):
```json
PUT movies/_doc/1
{ "title": "Spirited Away" }
```
Because you must specify an ID, if you run this command 10 times, you still have just one document indexed with the `_version` field incremented to 10.
Indexes default to one primary shard and one replica. If you want to specify non-default settings, create the index before adding documents:
```json
PUT more-movies
{ "settings": { "number_of_shards": 6, "number_of_replicas": 2 } }
```
## Naming restrictions for indexes
OpenSearch indexes have the following naming restrictions:
- All letters must be lowercase.
- Index names can't begin with underscores (`_`) or hyphens (`-`).
- Index names can't contain spaces, commas, or the following characters:
`:`, `"`, `*`, `+`, `/`, `\`, `|`, `?`, `#`, `>`, or `<`
## Read data
After you index a document, you can retrieve it by sending a GET request to the same endpoint that you used for indexing:
```json
GET movies/_doc/1
{
"_index" : "movies",
"_type" : "_doc",
"_id" : "1",
"_version" : 1,
"_seq_no" : 0,
"_primary_term" : 1,
"found" : true,
"_source" : {
"title" : "Spirited Away"
}
}
```
You can see the document in the `_source` object. If the document is not found, the `found` key is `false` and the `_source` object is not part of the response.
To retrieve multiple documents with a single command, use the `_mget` operation.
The format for retrieving multiple documents is similar to the `_bulk` operation, where you must specify the index and ID in the request body:
```json
GET _mget
{
"docs": [
{
"_index": "<index>",
"_id": "<id>"
},
{
"_index": "<index>",
"_id": "<id>"
}
]
}
```
To only return specific fields in a document:
```json
GET _mget
{
"docs": [
{
"_index": "<index>",
"_id": "<id>",
"_source": "field1"
},
{
"_index": "<index>",
"_id": "<id>",
"_source": "field2"
}
]
}
```
To check if a document exists:
```json
HEAD movies/_doc/<doc-id>
```
If the document exists, you get back a `200 OK` response, and if it doesn't, you get back a `404 - Not Found` error.
## Update data
To update existing fields or to add new fields, send a POST request to the `_update` operation with your changes in a `doc` object:
```json
POST movies/_update/1
{
"doc": {
"title": "Castle in the Sky",
"genre": ["Animation", "Fantasy"]
}
}
```
Note the updated `title` field and new `genre` field:
```json
GET movies/_doc/1
{
"_index" : "movies",
"_type" : "_doc",
"_id" : "1",
"_version" : 2,
"_seq_no" : 1,
"_primary_term" : 1,
"found" : true,
"_source" : {
"title" : "Castle in the Sky",
"genre" : [
"Animation",
"Fantasy"
]
}
}
```
The document also has an incremented `_version` field. Use this field to keep track of how many times a document is updated.
POST requests make partial updates to documents. To altogether replace a document, use a PUT request:
```json
PUT movies/_doc/1
{
"title": "Spirited Away"
}
```
The document with ID of 1 will contain only the `title` field, because the entire document will be replaced with the document indexed in this PUT request.
Use the `upsert` object to conditionally update documents based on whether they already exist. Here, if the document exists, its `title` field changes to `Castle in the Sky`. If it doesn't, OpenSearch indexes the document in the `upsert` object.
```json
POST movies/_update/2
{
"doc": {
"title": "Castle in the Sky"
},
"upsert": {
"title": "Only Yesterday",
"genre": ["Animation", "Fantasy"],
"date": 1993
}
}
```
#### Example response
```json
{
"_index" : "movies",
"_type" : "_doc",
"_id" : "2",
"_version" : 2,
"result" : "updated",
"_shards" : {
"total" : 2,
"successful" : 1,
"failed" : 0
},
"_seq_no" : 3,
"_primary_term" : 1
}
```
Each update operation for a document has a unique combination of the `_seq_no` and `_primary_term` values.
OpenSearch first writes your updates to the primary shard and then sends this change to all the replica shards. An uncommon issue can occur if multiple users of your OpenSearch-based application make updates to existing documents in the same index. In this situation, another user can read and update a document from a replica before it receives your update from the primary shard. Your update operation then ends up updating an older version of the document. In the best case, you and the other user make the same changes, and the document remains accurate. In the worst case, the document now contains out-of-date information.
To prevent this situation, use the `_seq_no` and `_primary_term` values in the request header:
```json
POST movies/_update/2?if_seq_no=3&if_primary_term=1
{
"doc": {
"title": "Castle in the Sky",
"genre": ["Animation", "Fantasy"]
}
}
```
If the document is updated after we retrieved it, the `_seq_no` and `_primary_term` values are different and our update operation fails with a `409 — Conflict` error.
When using the `_bulk` API, specify the `_seq_no` and `_primary_term` values within the action metadata.
## Delete data
To delete a document from an index, use a DELETE request:
```json
DELETE movies/_doc/1
```
The DELETE operation increments the `_version` field. If you add the document back to the same ID, the `_version` field increments again. This behavior occurs because OpenSearch deletes the document `_source`, but retains its metadata.

View File

@ -1,83 +0,0 @@
---
layout: default
title: Segment replication configuration
nav_order: 12
parent: Segment replication
---
# Segment replication configuration
Segment replication is an experimental feature. Therefore, we do not recommend the use of segment replication in a production environment. For updates on the progress of segment replication or if you want to leave feedback that could help improve the feature, see the [Segment replication issue](https://github.com/opensearch-project/OpenSearch/issues/2194).
{: .warning }
To enable the segment replication type, reference the steps below.
## Enabling the feature flag
There are several methods for enabling segment replication, depending on the install type. You will also need to set the replication strategy to `SEGMENT` when creating the index.
### Enable on a node using a tarball install
The flag is toggled using a new jvm parameter that is set either in `OPENSEARCH_JAVA_OPTS` or in config/jvm.options.
1. Option 1: Update config/jvm.options by adding the following line:
````json
-Dopensearch.experimental.feature.replication_type.enabled=true
````
1. Option 2: Use the `OPENSEARCH_JAVA_OPTS` environment variable:
````json
export OPENSEARCH_JAVA_OPTS="-Dopensearch.experimental.feature.replication_type.enabled=true"
````
1. Option 3: For developers using Gradle, update run.gradle by adding the following lines:
````json
testClusters {
runTask {
testDistribution = 'archive'
if (numZones > 1) numberOfZones = numZones
if (numNodes > 1) numberOfNodes = numNodes
systemProperty 'opensearch.experimental.feature.replication_type.enabled', 'true'
}
}
````
### Enable with Docker containers
If you're running Docker, add the following line to docker-compose.yml underneath the `opensearch-node` and `environment` section:
````json
OPENSEARCH_JAVA_OPTS="-Dopensearch.experimental.feature.replication_type.enabled=true" # Enables segment replication
````
### Setting the replication strategy on the index
To set the replication strategy to segment replication, create an index with replication.type set to `SEGMENT`:
````json
PUT /my-index1
{
"settings": {
"index": {
"replication.type": "SEGMENT"
}
}
}
````
## Known limitations
1. Enabling segment replication for an existing index requires [reindexing](https://github.com/opensearch-project/OpenSearch/issues/3685).
1. Rolling upgrades are currently not supported. Full cluster restarts are required when upgrading indexes using segment replication. [Issue 3881](https://github.com/opensearch-project/OpenSearch/issues/3881).
1. [Cross-cluster replication](https://github.com/opensearch-project/OpenSearch/issues/4090) does not currently use segment replication to copy between clusters.
1. Increased network congestion on primary shards. [Issue - Optimize network bandwidth on primary shards](https://github.com/opensearch-project/OpenSearch/issues/4245).
1. Shard allocation algorithms have not been updated to evenly spread primary shards across nodes.
1. Integration with remote-backed storage as the source of replication is [currently unsupported](https://github.com/opensearch-project/OpenSearch/issues/4448).
### Further resources regarding segment replication
1. [Known issues](https://github.com/opensearch-project/OpenSearch/issues/2194).
1. Steps for testing (link coming soon).
1. Segment replication blog post (link coming soon).

View File

@ -1,25 +0,0 @@
---
layout: default
title: Segment replication
nav_order: 64
has_children: true
redirect_from:
- /opensearch/segment-replication/
---
# Segment replication
Segment replication is an experimental feature with OpenSearch 2.3. Therefore, we do not recommend the use of segment replication in a production environment. For updates on the progress of segment replication or if you want leave feedback that could help improve the feature, see the [Segment replication git issue](https://github.com/opensearch-project/OpenSearch/issues/2194).
{: .warning}
With segment replication, segment files are copied across shards instead of documents being indexed on each shard copy. This improves indexing throughput and lowers resource utilization at the expense of increased network utilization.
As an experimental feature, segment replication will be behind a feature flag and must be enabled on **each node** of a cluster and pass a new setting during index creation.
{: .note }
### Potential use cases
- Users who have high write loads but do not have high search requirements and are comfortable with longer refresh times.
- Users with very high loads who want to add new nodes, as you do not need to index all nodes when adding a new node to the cluster.
This is the first step in a series of features designed to decouple reads and writes in order to lower compute costs.

View File

@ -1,8 +1,11 @@
---
layout: default
title: Aggregations
nav_order: 14
has_children: true
nav_order: 5
permalink: /aggregations/
redirect_from:
- /opensearch/aggregations/
---
# Aggregations

View File

@ -2,8 +2,10 @@
layout: default
title: Bucket aggregations
parent: Aggregations
nav_order: 2
has_children: false
permalink: /aggregations/bucket-agg/
nav_order: 3
redirect_from:
- /opensearch/bucket-agg/
---
# Bucket aggregations

View File

@ -2,8 +2,8 @@
layout: default
title: GeoHex grid aggregations
parent: Aggregations
permalink: /aggregations/geohexgrid/
nav_order: 4
has_children: false
---
# GeoHex grid aggregations

View File

@ -2,8 +2,10 @@
layout: default
title: Metric aggregations
parent: Aggregations
nav_order: 1
has_children: false
nav_order: 2
permalink: /aggregations/metric-agg/
redirect_from:
- /opensearch/metric-agg/
---
# Metric aggregations

View File

@ -2,7 +2,8 @@
layout: default
title: Pipeline aggregations
parent: Aggregations
nav_order: 4
nav_order: 5
permalink: /aggregations/pipeline-agg/
has_children: false
---

View File

@ -0,0 +1,43 @@
---
layout: default
title: Language analyzers
nav_order: 45
parent: Text analyzers
---
# Language analyzer
OpenSearch supports the following language values with the `analyzer` option:
arabic, armenian, basque, bengali, brazilian, bulgarian, catalan, czech, danish, dutch, english, estonian, finnish, french, galician, german, greek, hindi, hungarian, indonesian, irish, italian, latvian, lithuanian, norwegian, persian, portuguese, romanian, russian, sorani, spanish, swedish, turkish, and thai.
To use the analyzer when you map an index, specify the value within your query. For example, to map your index with the French language analyzer, specify the `french` value for the analyzer field:
```json
"analyzer": "french"
```
#### Sample Request
The following query maps an index with the language analyzer set to `french`:
```json
PUT my-index-000001
{
"mappings": {
"properties": {
"text": {
"type": "text",
"fields": {
"french": {
"type": "text",
"analyzer": "french"
}
}
}
}
}
}
```
<!-- TO do: each of the options needs its own section with an example. Convert table to individual sections, and then give a streamlined list with valid values. -->

View File

@ -2,9 +2,11 @@
layout: default
title: Refresh search analyzer
nav_order: 50
has_children: false
redirect_from: /im-plugin/refresh-analyzer/
parent: Text analyzers
has_toc: false
redirect_from:
- /im-plugin/refresh-analyzer/
- /im-plugin/refresh-analyzer/index/
---
# Refresh search analyzer

View File

@ -1,8 +1,11 @@
---
layout: default
title: Text analyzers
parent: Query DSL
nav_order: 75
nav_order: 190
has_children: true
permalink: /analyzers/text-analyzers/
redirect_from:
- /opensearch/query-dsl/text-analyzers/
---
@ -52,7 +55,7 @@ Each analyzer consists of one tokenizer and zero or more token filters. Differen
Option | Valid values | Description
:--- | :--- | :---
`analyzer` | `standard, simple, whitespace, stop, keyword, pattern, language, fingerprint` | The analyzer you want to use for the query. Different analyzers have different character filters, tokenizers, and token filters. The `stop` analyzer, for example, removes stop words (for example, "an," "but," "this") from the query string. For a full list of acceptable language values, see [Language analyzer](#language-analyzer) on this page.
`analyzer` | `standard, simple, whitespace, stop, keyword, pattern, language, fingerprint` | The analyzer you want to use for the query. Different analyzers have different character filters, tokenizers, and token filters. The `stop` analyzer, for example, removes stop words (for example, "an," "but," "this") from the query string. For a full list of acceptable language values, see [Language analyzer]({{site.url}}{{site.baseurl}}/query-dsl/analyzers/language-analyzers/) on this page.
`quote_analyzer` | String | This option lets you choose to use the standard analyzer without any options, such as `language` or other analyzers. Usage is `"quote_analyzer": "standard"`.
<!-- This is a list of the 7 individual new pages we need to write
@ -69,40 +72,3 @@ If you want to select one of the text analyzers, see [Text analyzers reference](
1. Language
1. Fingerprint
-->
## Language analyzer
OpenSearch supports the following language values with the `analyzer` option:
arabic, armenian, basque, bengali, brazilian, bulgarian, catalan, czech, danish, dutch, english, estonian, finnish, french, galician, german, greek, hindi, hungarian, indonesian, irish, italian, latvian, lithuanian, norwegian, persian, portuguese, romanian, russian, sorani, spanish, swedish, turkish, and thai.
To use the analyzer when you map an index, specify the value within your query. For example, to map your index with the French language analyzer, specify the `french` value for the analyzer field:
```json
"analyzer": "french"
```
#### Sample Request
The following query maps an index with the language analyzer set to `french`:
```json
PUT my-index-000001
{
"mappings": {
"properties": {
"text": {
"type": "text",
"fields": {
"french": {
"type": "text",
"analyzer": "french"
}
}
}
}
}
}
```
<!-- TO do: each of the options needs its own section with an example. Convert table to individual sections, and then give a streamlined list with valid values. -->

View File

@ -4,6 +4,9 @@ title: Boolean queries
parent: Compound queries
grand_parent: Query DSL
nav_order: 10
permalink: /query-dsl/compound/bool/
redirect_from:
- /opensearch/query-dsl/compound/bool/
---
# Boolean queries

View File

@ -4,6 +4,9 @@ title: Compound queries
parent: Query DSL
has_children: true
nav_order: 40
permalink: /query-dsl/compound/
redirect_from:
- /opensearch/query-dsl/compound/index/
---
# Compound queries

View File

@ -4,8 +4,10 @@ title: Full-text queries
parent: Query DSL
has_children: true
nav_order: 30
permalink: /query-dsl/full-text/
redirect_from:
- /opensearch/query-dsl/full-text/
- /opensearch/query-dsl/full-text/index/
---
# Full-text queries

View File

@ -4,6 +4,9 @@ title: Query string queries
parent: Full-text queries
grand_parent: Query DSL
nav_order: 25
permalink: /query-dsl/full-text/query-string/
redirect_from:
- /opensearch/query-dsl/full-text/query-string/
---
# Query string queries

View File

@ -4,6 +4,9 @@ title: Geo-bounding box queries
parent: Geographic and xy queries
grand_parent: Query DSL
nav_order: 10
permalink: /query-dsl/geo-and-xy/geo-bounding-box/
redirect_from:
- /opensearch/query-dsl/geo-and-xy/geo-bounding-box/
---
# Geo-bounding box queries

View File

@ -4,6 +4,9 @@ title: Geographic and xy queries
parent: Query DSL
has_children: true
nav_order: 50
permalink: /query-dsl/geo-and-xy/
redirect_from:
- /opensearch/query-dsl/geo-and-xy/index/
---
# Geographic and xy queries

View File

@ -4,6 +4,9 @@ title: xy queries
parent: Geographic and xy queries
grand_parent: Query DSL
nav_order: 50
permalink: /query-dsl/geo-and-xy/xy/
redirect_from:
- /opensearch/query-dsl/geo-and-xy/xy/
---
# xy queries

View File

@ -1,10 +1,12 @@
---
layout: default
title: Query DSL
nav_order: 27
nav_order: 2
has_children: true
permalink: /query-dsl/
redirect_from:
- /opensearch/query-dsl/
- /opensearch/query-dsl/index/
- /docs/opensearch/query-dsl/
---

View File

@ -2,6 +2,7 @@
layout: default
title: Query and filter context
parent: Query DSL
permalink: /query-dsl/query-filter-context/
nav_order: 5
---

View File

@ -3,6 +3,9 @@ layout: default
title: Span queries
parent: Query DSL
nav_order: 60
permalink: /query-dsl/span-query/
redirect_from:
- /opensearch/query-dsl/span-query/
---
# Span queries

View File

@ -2,6 +2,7 @@
layout: default
title: Term-level and full-text queries compared
parent: Query DSL
permalink: /query-dsl/term-vs-full-text/
nav_order: 10
---

View File

@ -3,6 +3,9 @@ layout: default
title: Term-level queries
parent: Query DSL
nav_order: 20
permalink: /query-dsl/term/
redirect_from:
- /opensearch/query-dsl/term/
---
# Term-level queries

View File

@ -1,9 +1,11 @@
---
layout: default
title: Neural Search plugin
nav_order: 1
nav_order: 200
has_children: false
has_toc: false
redirect_from:
- /neural-search-plugin/index/
---
# Neural Search plugin

View File

@ -1,9 +1,11 @@
---
layout: default
title: Point in Time API
nav_order: 58
nav_order: 59
has_children: false
parent: Point in Time
redirect_from:
- /opensearch/point-in-time-api/
---
# Point in Time API

View File

@ -4,6 +4,8 @@ title: Point in Time
nav_order: 58
has_children: true
has_toc: false
redirect_from:
- /opensearch/point-in-time/
---
# Point in Time

View File

@ -4,7 +4,7 @@ title: Querqy
has_children: false
redirect_from:
- /search-plugins/querqy/
nav_order: 10
nav_order: 210
---
# Querqy

View File

@ -2,6 +2,8 @@
layout: default
title: Search templates
nav_order: 50
redirect_from:
- /opensearch/search-template/
---
# Search templates

View File

@ -3,6 +3,8 @@ layout: default
title: Autocomplete
parent: Searching data
nav_order: 24
redirect_from:
- /opensearch/search/autocomplete/
---
# Autocomplete functionality

View File

@ -3,6 +3,8 @@ layout: default
title: Highlight query matches
parent: Searching data
nav_order: 23
redirect_from:
- /opensearch/search/highlight/
---
# Highlight query matches

View File

@ -1,7 +1,7 @@
---
layout: default
title: Searching data
nav_order: 20
nav_order: 5
has_children: true
has_toc: false
redirect_from: /opensearch/ux/

View File

@ -3,6 +3,8 @@ layout: default
title: Paginate results
parent: Searching data
nav_order: 21
redirect_from:
- /opensearch/search/paginate/
---
## Paginate results

View File

@ -3,6 +3,8 @@ layout: default
title: Sort results
parent: Searching data
nav_order: 22
redirect_from:
- /opensearch/search/sort/
---
## Sort results

View File

@ -92,8 +92,7 @@ Connected as CN=node-0.example.com,OU=SSL,O=Test,L=Test,C=DE
ERR: CN=node-0.example.com,OU=SSL,O=Test,L=Test,C=DE is not an admin user
```
You must use an admin certificate when executing the script. To learn more, see [Configure admin certificates]({{site.url}}{{site.baseurl}}/security/configuration/tls#configuring-admin-certificates).
You must use an admin certificate when executing the script. To learn more, see [Configure admin certificates]({{site.url}}{{site.baseurl}}/security/configuration/tls/#configuring-admin-certificates).
## Use the diagnose option

View File

@ -7,6 +7,7 @@ has_children: false
grand_parent: Availability and Recovery
redirect_from:
- /opensearch/snapshots/snapshot-restore/
- /availability-and-recovery/snapshots/snapshot-restore/
---
# Take and restore snapshots

View File

@ -182,7 +182,7 @@ If you are migrating an Open Distro for Elasticsearch cluster, we recommend firs
## Upgrade tool
The `opensearch-upgrade` tool lets you automate some of the steps in [Upgrade to OpenSearch]({{site.url}}{{site.baseurl}}/upgrade-to/upgrade-to/#migrate-to-opensearch), eliminating the need for error-prone manual operations.
The `opensearch-upgrade` tool lets you automate some of the steps in [Migrate to OpenSearch](#migrate-to-opensearch), eliminating the need for error-prone manual operations.
The `opensearch-upgrade` tool performs the following functions:
@ -202,8 +202,7 @@ The `opensearch-upgrade` tool doesn't perform an end-to-end upgrade:
To perform a rolling upgrade using the [OpenSearch tarball]({{site.url}}{{site.baseurl}}/opensearch/install/tar/) distribution:
Check [Upgrade paths]({{site.url}}{{site.baseurl}}/upgrade-to/upgrade-to/#migration-paths) to make sure that the version youre upgrading to is supported and whether you need to upgrade to a supported Elasticsearch OSS version first.
{: .note }
Check [Upgrade paths](#migration-paths) to make sure that the version youre upgrading to is supported and whether you need to upgrade to a supported Elasticsearch OSS version first.
1. Disable shard allocation to prevent Elasticsearch OSS from replicating shards as you shut down nodes: