### Example Response for Starting Container Source: https://github.com/opensearch-project/documentation-website/blob/main/_migrate-or-upgrade/rolling-upgrade/rolling-upgrade-lab.md This is an example of the output received after successfully starting a new OpenSearch Docker container. ```bash 7b802865bd6eb420a106406a54fc388ed8e5e04f6cbd908c2a214ea5ce72ac00 ``` -------------------------------- ### Example Response: Start New Node Container Source: https://github.com/opensearch-project/documentation-website/blob/main/_migrate-or-upgrade/rolling-upgrade/rolling-upgrade-lab.md Example output showing the container ID of the newly started OpenSearch node. ```bash d26d0cb2e1e93e9c01bb00f19307525ef89c3c3e306d75913860e6542f729ea4 ``` -------------------------------- ### Start OpenSearch Service Source: https://github.com/opensearch-project/documentation-website/blob/main/_tuning-your-cluster/index.md Use this command to start the OpenSearch service after installation. Ensure you have followed the systemd service setup if installing from a tar archive. ```bash sudo systemctl start opensearch.service ``` -------------------------------- ### Insert API example with client setup Source: https://github.com/opensearch-project/documentation-website/blob/main/DEVELOPER_GUIDE.md Enable client setup rendering by setting include_client_setup to true. ```markdown ``` -------------------------------- ### REST API Example with Client Setup Source: https://github.com/opensearch-project/documentation-website/blob/main/DEVELOPER_GUIDE.md Shows how to include a REST API call and automatically render the client setup code for various languages. ```APIDOC ## PUT /_settings?expand_wildcards=all&analyze_wildcard ### Description This endpoint is used to update settings for an index, potentially using wildcards, and includes client setup instructions. ### Method PUT ### Endpoint /_settings?expand_wildcards=all&analyze_wildcard ### Request Body - **index** (object) - Required - Contains index-specific settings. - **number_of_replicas** (integer) - Required - The number of replicas for the index. ### Client Setup (Client setup code for various languages will be rendered here) ``` -------------------------------- ### OpenSearch Plugins List Example Source: https://github.com/opensearch-project/documentation-website/blob/main/_install-and-configure/install-opensearch/windows.md This is an example of the output when querying the `_cat/plugins` endpoint, showing installed plugins and their versions. ```text hostname opensearch-alerting {{site.opensearch_version}} hostname opensearch-anomaly-detection {{site.opensearch_version}} hostname opensearch-asynchronous-search {{site.opensearch_version}} hostname opensearch-cross-cluster-replication {{site.opensearch_version}} hostname opensearch-geospatial {{site.opensearch_version}} hostname opensearch-index-management {{site.opensearch_version}} hostname opensearch-job-scheduler {{site.opensearch_version}} hostname opensearch-knn {{site.opensearch_version}} hostname opensearch-ml {{site.opensearch_version}} hostname opensearch-neural-search {{site.opensearch_version}} hostname opensearch-notifications {{site.opensearch_version}} hostname opensearch-notifications-core {{site.opensearch_version}} hostname opensearch-observability {{site.opensearch_version}} hostname opensearch-reports-scheduler {{site.opensearch_version}} hostname opensearch-security {{site.opensearch_version}} hostname opensearch-security-analytics {{site.opensearch_version}} hostname opensearch-sql {{site.opensearch_version}} ``` -------------------------------- ### Configure Workflow Sample Source: https://github.com/opensearch-project/documentation-website/blob/main/_migration-assistant/workflow-cli/index.md Shows the sample schema for your installed version or loads it as your starting point. ```bash workflow configure sample ``` ```bash workflow configure sample --load ``` -------------------------------- ### Start OpenSearch Dashboards via command line Source: https://github.com/opensearch-project/documentation-website/blob/main/_install-and-configure/install-dashboards/windows.md Commands to navigate to the installation directory and execute the batch script to start the service. ```bat cd \path\to\opensearch-dashboards-{{site.opensearch_dashboards_version}} ``` ```bat .\bin\opensearch-dashboards.bat ``` -------------------------------- ### ICU Normalizer Setup and Usage Source: https://github.com/opensearch-project/documentation-website/blob/main/_analyzers/character-filters/icu-normalization.md This section covers the setup and usage of the icu_normalizer character filter, including installation requirements, normalization modes, parameters, and examples for default, NFD, and selective normalization. ```APIDOC ## ICU Normalization Character Filter The `icu_normalizer` character filter converts text into a canonical Unicode form by applying one of the normalization modes defined in [Unicode Standard Annex #15](http://unicode.org/reports/tr15/). This process standardizes character representations before tokenization, ensuring that equivalent characters are treated consistently. ### Installation The `icu_normalizer` character filter requires the `analysis-icu` plugin. For installation instructions, see [ICU analyzer]({{site.url}}{{site.baseurl}}/analyzers/language-analyzers/icu/). ### Normalization Modes The character filter supports the following Unicode normalization forms: - `nfc` (Canonical Decomposition, followed by Canonical Composition): Decomposes combined characters, then recomposes them in a standard order. This is the most common normalization form. - `nfd` (Canonical Decomposition): Decomposes combined characters into their constituent parts. For example, `é` becomes `e` + combining acute accent. - `nfkc` (Compatibility Decomposition, followed by Canonical Composition): Applies compatibility decompositions (converting visually similar characters to a standard form), then canonical composition. - `nfkc_cf` (Default): Applies NFKC normalization with case folding. This mode normalizes both character representations and case. ### Parameters The following table lists the parameters for the `icu_normalizer` character filter. Parameter | Data type | Description :--- | :--- | :--- `name` | String | The Unicode normalization form to apply. Valid values are `nfc`, `nfd`, `nfkc`, and `nfkc_cf`. Default is `nfkc_cf`. `mode` | String | The normalization mode. Valid values are `compose` (default) and `decompose`. When `decompose` is specified, `nfc` becomes `nfd` and `nfkc` becomes `nfkd`. `unicode_set_filter` | String | A [UnicodeSet](https://unicode-org.github.io/icu/userguide/strings/unicodeset.html) expression that specifies which characters to normalize. Optional. If not specified, all characters are normalized. ### Example: Default normalization The following example demonstrates using the default `nfkc_cf` normalization: ```json PUT /icu-norm-default { "settings": { "analysis": { "analyzer": { "default_icu_normalizer": { "tokenizer": "keyword", "char_filter": ["icu_normalizer"] } } } } } ``` Test the normalizer with text containing ligatures and case variations: ```json POST /icu-norm-default/_analyze { "analyzer": "default_icu_normalizer", "text": "financial AFFAIRS" } ``` The response shows normalization and case folding: ```json { "tokens": [ { "token": "financial affairs", "start_offset": 0, "end_offset": 16, "type": "word", "position": 0 } ] } ``` ### Example: NFD (decomposed) normalization The following example configures NFD normalization by setting `mode` to `decompose`: ```json PUT /icu-norm-nfd { "settings": { "analysis": { "char_filter": { "nfd_normalizer": { "type": "icu_normalizer", "name": "nfc", "mode": "decompose" } }, "analyzer": { "nfd_analyzer": { "tokenizer": "keyword", "char_filter": ["nfd_normalizer"] } } } } } ``` Test with accented characters: ```json POST /icu-norm-nfd/_analyze { "analyzer": "nfd_analyzer", "text": "café" } ``` The NFD normalization decomposes the accented character: ```json { "tokens": [ { "token": "café", "start_offset": 0, "end_offset": 4, "type": "word", "position": 0 } ] } ``` Note: While the visual representation appears the same, the underlying character encoding has changed from a single precomposed character to separate base and combining characters. ### Example: Selective normalization with unicode_set_filter You can limit normalization to specific character ranges using the `unicode_set_filter` parameter: ```json PUT /icu-norm-selective { "settings": { "analysis": { "char_filter": { "latin_only_normalizer": { "type": "icu_normalizer", "name": "nfkc_cf", "unicode_set_filter": "[\\u0000-\\u024F]" } }, "analyzer": { "selective_normalizer": { "tokenizer": "keyword", "char_filter": ["latin_only_normalizer"] } } } } } ``` This configuration normalizes only Latin characters (Unicode range U+0000 to U+024F), leaving other scripts unchanged. ``` -------------------------------- ### Request hot shard identification RCA Source: https://github.com/opensearch-project/documentation-website/blob/main/_monitoring-your-cluster/pa/rca/shard-hotspot.md Use this GET request to initiate the hot shard identification RCA. No specific setup is required beyond having the performance analyzer plugin installed. ```bash GET _plugins/_performanceanalyzer/rca?name=HotShardClusterRca ``` -------------------------------- ### Example Get Model Request Source: https://github.com/opensearch-project/documentation-website/blob/main/_ml-commons-plugin/api/model-apis/get-model.md This is an example of a GET request to retrieve a model with a specific ID. ```http GET /_plugins/_ml/models/N8AE1osB0jLkkocYjz7D ``` -------------------------------- ### Install the SDK Source: https://github.com/opensearch-project/documentation-website/blob/main/_observing-your-data/agent-traces/instrument.md Install the base package and optional dependencies for specific providers. ```bash pip install opensearch-genai-observability-sdk-py ``` ```bash pip install opensearch-genai-observability-sdk-py[openai,langchain] ``` -------------------------------- ### Example Get Connector Request Source: https://github.com/opensearch-project/documentation-website/blob/main/_ml-commons-plugin/api/connector-apis/get-connector.md An example of a GET request to retrieve a connector with a specific ID. ```json GET /_plugins/_ml/connectors/N8AE1osB0jLkkocYjz7D ``` -------------------------------- ### Start OpenSearch with Security Demo Configuration Source: https://github.com/opensearch-project/documentation-website/blob/main/_install-and-configure/install-opensearch/tar.md Execute the startup script to launch OpenSearch using the default security demo configuration. ```bash ./opensearch-tar-install.sh ``` -------------------------------- ### Example Request to Get Context Management Source: https://github.com/opensearch-project/documentation-website/blob/main/_ml-commons-plugin/api/context-management-apis/get-context-management.md This is an example of a GET request to retrieve the 'token-aware-truncation' context management configuration. ```json GET /_plugins/_ml/context_management/token-aware-truncation ``` -------------------------------- ### Install opensearch-dsl Source: https://github.com/opensearch-project/documentation-website/blob/main/_clients/python-high-level.md Install the client using pip. This is the first step to adding the client to your project. ```bash pip install opensearch-dsl ``` -------------------------------- ### Example Request for Get ML Task Source: https://github.com/opensearch-project/documentation-website/blob/main/_ml-commons-plugin/api/tasks-apis/get-task.md An example of how to call the Get ML Task API with a specific task ID. ```json GET /_plugins/_ml/tasks/MsBi1YsB0jLkkocYjD5f ``` -------------------------------- ### Run demo configuration on Windows Source: https://github.com/opensearch-project/documentation-website/blob/main/_security/configuration/demo-configuration.md Execute the batch installation script for ZIP distributions. ```powershell > .\opensearch-windows-install.bat ``` -------------------------------- ### Compare Sample Queries (Source) Source: https://github.com/opensearch-project/documentation-website/blob/main/_migration-assistant/playbook-amazon-opensearch-service-to-serverless.md Runs a sample query on the source cluster to retrieve the first 5 documents and display them in a pretty format. ```bash console clusters curl source //_search?size=5&pretty ``` -------------------------------- ### Example response for Get Template API Source: https://github.com/opensearch-project/documentation-website/blob/main/_api-reference/index-apis/get-template-legacy.md An example JSON response when retrieving an index template using the deprecated Get Template API. ```json { "sample-template": { "order": 1, "index_patterns": [ "sample-*" ], "settings": { "number_of_shards": "1" }, "mappings": { "properties": { "timestamp": { "type": "date" } } }, "aliases": {} } } ``` -------------------------------- ### Get a specific template example Source: https://github.com/opensearch-project/documentation-website/blob/main/_api-reference/index-apis/get-template-legacy.md Example of how to retrieve a specific index template named 'sample-template' using the deprecated Get Template API. The Python client is shown. ```rest GET /_template/sample-template ``` ```python response = client.indices.get_template( name = "sample-template" ) ``` -------------------------------- ### Start OpenSearch Source: https://github.com/opensearch-project/documentation-website/blob/main/_install-and-configure/install-opensearch/windows.md Execute the OpenSearch startup script to launch the service after configuration changes. ```bash \path\to\opensearch-{{site.opensearch_version}}\bin\opensearch.bat ``` -------------------------------- ### Start OpenSearch Dashboards Service Source: https://github.com/opensearch-project/documentation-website/blob/main/_install-and-configure/install-dashboards/rpm.md Start the OpenSearch Dashboards service after installation or enabling. ```bash sudo systemctl start opensearch-dashboards ``` -------------------------------- ### Install OpenSearch CLI Source: https://github.com/opensearch-project/documentation-website/blob/main/_tools/cli.md Commands to set up the CLI executable and verify the installation. ```bash chmod +x ./opensearch-cli ``` ```bash export PATH=$PATH:$(pwd) ``` ```bash opensearch-cli --version ``` -------------------------------- ### Start Replication Response Example Source: https://github.com/opensearch-project/documentation-website/blob/main/_tuning-your-cluster/replication-plugin/api.md Confirms that the replication start request has been acknowledged by the cluster. ```json { "acknowledged": true } ``` -------------------------------- ### Logstash Plugin Installation Output Source: https://github.com/opensearch-project/documentation-website/blob/main/_tools/logstash/index.md Example output indicating a successful installation of the logstash-output-opensearch plugin. ```text Validating logstash-output-opensearch Resolving mixin dependencies Updating mixin dependencies logstash-mixin-ecs_compatibility_support Bundler attempted to update logstash-mixin-ecs_compatibility_support but its version stayed the same Installing logstash-output-opensearch Installation successful ``` -------------------------------- ### Display OpenSearch Benchmark help Source: https://github.com/opensearch-project/documentation-website/blob/main/_benchmark/user-guide/install-and-configure/installing-benchmark.md After installation, use this command to view available options and usage instructions for OpenSearch Benchmark. ```bash opensearch-benchmark -h ``` -------------------------------- ### Example Request: Get Index Settings Source: https://github.com/opensearch-project/documentation-website/blob/main/API_STYLE_GUIDE.md This example demonstrates how to retrieve the settings for a specific index. ```APIDOC ## Example request ```json GET /sample-index1/_settings ``` ``` -------------------------------- ### Basic Join Syntax Examples Source: https://github.com/opensearch-project/documentation-website/blob/main/_sql-and-ppl/ppl/commands/join.md Demonstrates various ways to use the basic `join` command syntax, including different join types, aliases, and join criteria. ```sql source = table1 | inner join left = l right = r on l.a = r.a table2 | fields l.a, r.a, b, c ``` ```sql source = table1 | inner join left = l right = r where l.a = r.a table2 | fields l.a, r.a, b, c ``` ```sql source = table1 | left join left = l right = r on l.a = r.a table2 | fields l.a, r.a, b, c ``` ```sql source = table1 | right join left = l right = r on l.a = r.a table2 | fields l.a, r.a, b, c ``` ```sql source = table1 | full left = l right = r on l.a = r.a table2 | fields l.a, r.a, b, c ``` ```sql source = table1 | cross join left = l right = r on 1=1 table2 ``` ```sql source = table1 | left semi join left = l right = r on l.a = r.a table2 ``` ```sql source = table1 | left anti join left = l right = r on l.a = r.a table2 ``` ```sql source = table1 | join left = l right = r [ source = table2 | where d > 10 | head 5 ] | fields l.a, s.a ``` ```sql source = table1 | inner join on table1.a = table2.a table2 | fields table1.a, table2.a, table1.b, table1.c ``` ```sql source = table1 | inner join on a = c table2 | fields a, b, c, d ``` ```sql source = table1 as t1 | join left = l right = r on l.a = r.a table2 as t2 | fields l.a, r.a ``` ```sql source = table1 as t1 | join left = l right = r on l.a = r.a table2 as t2 | fields t1.a, t2.a ``` ```sql source = table1 | join left = l right = r on l.a = r.a [ source = table2 ] as s | fields l.a, s.a ``` -------------------------------- ### Complete OpenSearch Ruby client sample program Source: https://github.com/opensearch-project/documentation-website/blob/main/_clients/ruby.md A comprehensive example demonstrating index lifecycle management, document CRUD, bulk operations, and search queries. ```ruby require 'opensearch' client = OpenSearch::Client.new(host: 'http://localhost:9200') # Create an index with non-default settings index_name = 'students' index_body = { 'settings': { 'index': { 'number_of_shards': 1, 'number_of_replicas': 2 } } } client.indices.create( index: index_name, body: index_body ) # Create a mapping client.indices.put_mapping( index: index_name, body: { properties: { first_name: { type: 'keyword' }, last_name: { type: 'keyword' } } } ) # Get mappings response = client.indices.get_mapping(index: index_name) puts 'Mappings for the students index:' puts MultiJson.dump(response, pretty: "true") # Add one document to the index puts 'Adding one document:' document = { first_name: 'Connor', last_name: 'James', gpa: 3.93, grad_year: 2021 } id = 100 client.index( index: index_name, body: document, id: id, refresh: true ) response = client.search(index: index_name) puts MultiJson.dump(response, pretty: "true") # Update a document puts 'Updating a document:' client.update(index: index_name, id: id, body: { doc: { gpa: 3.25 } }, refresh: true) response = client.search(index: index_name) puts MultiJson.dump(response, pretty: "true") print 'The updated gpa is ' puts response['hits']['hits'].map { |doc| doc['_source']['gpa'] } # Add many documents in bulk documents = [ { index: { _index: index_name, _id: '200' } }, { first_name: 'James', last_name: 'Rodriguez', gpa: 3.91, grad_year: 2019}, { index: { _index: index_name, _id: '300' } }, { first_name: 'Nikki', last_name: 'Wolf', gpa: 3.87, grad_year: 2020} ] client.bulk(body: documents, refresh: true) # Get all documents in the index response = client.search(index: index_name) puts 'All documents in the index after bulk upload:' puts MultiJson.dump(response, pretty: "true") # Search for a document using a multi_match query puts 'Searching for documents that match "James":' q = 'James' query = { 'size': 5, 'query': { 'multi_match': { 'query': q, 'fields': ['first_name', 'last_name^2'] } } } response = client.search( body: query, index: index_name ) puts MultiJson.dump(response, pretty: "true") # Delete the document response = client.delete( index: index_name, id: id, refresh: true ) response = client.search(index: index_name) puts 'Documents in the index after one document was deleted:' puts MultiJson.dump(response, pretty: "true") # Delete multiple documents actions = [ { delete: { _index: index_name, _id: 200 } }, { delete: { _index: index_name, _id: 300 } } ] client.bulk(body: actions, refresh: true) response = client.search(index: index_name) puts 'Documents in the index after all documents were deleted:' puts MultiJson.dump(response, pretty: "true") ``` -------------------------------- ### Install Repository Plugin Source: https://github.com/opensearch-project/documentation-website/blob/main/_install-and-configure/install-opensearch/operator/operator-opensearch-config.md Install the appropriate cloud provider native plugin for snapshot repository configuration. This example shows how to install the repository-s3 plugin. ```yaml spec: general: pluginsList: ["repository-s3"] ``` -------------------------------- ### Start OpenSearch Dashboards (Systemd) Source: https://github.com/opensearch-project/documentation-website/blob/main/_security/configuration/disable-enable-security.md Command to start OpenSearch Dashboards when managed by systemd (RPM/Debian installations). ```bash sudo systemctl start opensearch-dashboards ``` -------------------------------- ### Initialize a new Go module Source: https://github.com/opensearch-project/documentation-website/blob/main/_clients/go.md Use this command to start a new Go project that will include the OpenSearch client. ```go go mod init ``` -------------------------------- ### Example Agent Retrieval Request Source: https://github.com/opensearch-project/documentation-website/blob/main/_ml-commons-plugin/api/agent-apis/get-agent.md An example of a GET request to retrieve a specific agent using its ID. ```json GET /_plugins/_ml/agents/N8AE1osB0jLkkocYjz7D ``` -------------------------------- ### Sample Program for OpenSearch Operations Source: https://github.com/opensearch-project/documentation-website/blob/main/_clients/python-low-level.md A comprehensive example demonstrating client initialization, index creation, document indexing, and basic output handling. ```python from opensearchpy import OpenSearch host = 'localhost' port = 9200 auth = ('admin', 'admin') # For testing only. Don't store credentials in code. ca_certs_path = '/full/path/to/root-ca.pem' # Provide a CA bundle if you use intermediate CAs with your root CA. # Optional client certificates if you don't want to use HTTP basic authentication. # client_cert_path = '/full/path/to/client.pem' # client_key_path = '/full/path/to/client-key.pem' # Create the client with SSL/TLS enabled, but hostname verification disabled. client = OpenSearch( hosts = [{'host': host, 'port': port}], http_compress = True, # enables gzip compression for request bodies http_auth = auth, # client_cert = client_cert_path, # client_key = client_key_path, use_ssl = True, verify_certs = True, ssl_assert_hostname = False, ssl_show_warn = False, ca_certs = ca_certs_path ) # Create an index with non-default settings. index_name = 'python-test-index' index_body = { 'settings': { 'index': { 'number_of_shards': 4 } } } response = client.indices.create(index=index_name, body=index_body) print('\nCreating index:') print(response) # Add a document to the index. document = { 'title': 'Moneyball', 'director': 'Bennett Miller', 'year': '2011' } id = '1' response = client.index( index = index_name, body = document, id = id, refresh = True ) print('\nAdding document:') print(response) ``` -------------------------------- ### Example Request for Workflow Status Source: https://github.com/opensearch-project/documentation-website/blob/main/_automating-configurations/api/get-workflow-status.md This is an example of a request to get the status of a specific workflow using its ID. ```json GET /_plugins/_flow_framework/workflow/8xL8bowB8y25Tqfenm50/_status ``` -------------------------------- ### Configure OpenSearch with startup flags Source: https://github.com/opensearch-project/documentation-website/blob/main/_install-and-configure/configuring-opensearch/index.md Pass configuration directly to the JVM process at startup using the -E flag. ```bash ./opensearch -Ecluster.name=opensearch-cluster -Enode.name=opensearch-node1 -Ehttp.host=0.0.0.0 -Ediscovery.type=single-node ``` -------------------------------- ### Card Configuration Example Source: https://github.com/opensearch-project/documentation-website/blob/main/FORMATTING_GUIDE.md Define tutorial cards in the front matter using YAML. The `heading`, `description`, `link`, and `list` are used to structure card content. ```yaml tutorial_cards: - heading: "Getting started with semantic and hybrid search" description: "Learn how to implement semantic and hybrid search" link: "/vector-search/tutorials/neural-search-tutorial/" list: - "Platform: OpenSearch" - "Model: Anthropic Claude" - "Deployment: Amazon Bedrock" ``` -------------------------------- ### Install an OpenSearch plugin Source: https://github.com/opensearch-project/documentation-website/blob/main/_install-and-configure/plugins.md Use the install command to add a plugin. Note that some plugins require additional security permissions and may prompt for confirmation. ```console $ sudo ./opensearch-plugin install org.opensearch.plugin:opensearch-anomaly-detection:2.2.0.0 -> Installing org.opensearch.plugin:opensearch-anomaly-detection:2.2.0.0 -> Downloading org.opensearch.plugin:opensearch-anomaly-detection:2.2.0.0 from maven central [=================================================] 100% @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: plugin requires additional permissions @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ * java.lang.RuntimePermission accessClassInPackage.sun.misc * java.lang.RuntimePermission accessDeclaredMembers * java.lang.RuntimePermission getClassLoader * java.lang.RuntimePermission setContextClassLoader * java.lang.reflect.ReflectPermission suppressAccessChecks * java.net.SocketPermission * connect,resolve * javax.management.MBeanPermission org.apache.commons.pool2.impl.GenericObjectPool#-[org.apache.commons.pool2:name=pool,type=GenericObjectPool] registerMBean * javax.management.MBeanPermission org.apache.commons.pool2.impl.GenericObjectPool#-[org.apache.commons.pool2:name=pool,type=GenericObjectPool] unregisterMBean * javax.management.MBeanServerPermission createMBeanServer * javax.management.MBeanTrustPermission register See http://docs.oracle.com/javase/8/docs/technotes/guides/security/permissions.html for descriptions of what these permissions allow and the associated risks. Continue with installation? [y/N]y -> Installed opensearch-anomaly-detection with folder name opensearch-anomaly-detection ``` -------------------------------- ### Example: Get Specific SM Policy Source: https://github.com/opensearch-project/documentation-website/blob/main/_tuning-your-cluster/availability-and-recovery/snapshots/sm-api.md An example of retrieving a specific snapshot management policy named 'daily-policy'. ```json GET _plugins/_sm/policies/daily-policy ``` -------------------------------- ### Install OpenSearch with Disabled Demo Security Config Source: https://github.com/opensearch-project/documentation-website/blob/main/_install-and-configure/install-opensearch/debian.md Use this command to install OpenSearch and prevent the installer from setting up demo security configuration. This is useful for manual security setup. ```bash sudo env DISABLE_INSTALL_DEMO_CONFIG=true dpkg -i opensearch-{{site.opensearch_version}}-linux-x64.deb ``` -------------------------------- ### Compare Sample Queries (Target) Source: https://github.com/opensearch-project/documentation-website/blob/main/_migration-assistant/playbook-amazon-opensearch-service-to-serverless.md Runs a sample query on the target cluster to retrieve the first 5 documents and display them in a pretty format. ```bash console clusters curl target //_search?size=5&pretty ``` -------------------------------- ### Start OpenSearch Container Source: https://github.com/opensearch-project/documentation-website/blob/main/_tools/logstash/index.md Launch an OpenSearch instance attached to the test network. ```bash docker run -p 9200:9200 -p 9600:9600 --name opensearch --net test -e "discovery.type=single-node" opensearchproject/opensearch:1.2.0 ``` -------------------------------- ### Sample Program: Full OpenSearch Workflow Source: https://github.com/opensearch-project/documentation-website/blob/main/_clients/python-high-level.md A comprehensive sample program demonstrating client creation, index creation with settings, document insertion, bulk operations, searching, document deletion, and index deletion. ```python from opensearchpy import OpenSearch from opensearch_dsl import Search, Document, Text, Keyword host = 'localhost' port = 9200 auth = ('admin', 'admin') # For testing only. Don't store credentials in code. ca_certs_path = 'root-ca.pem' # Create the client with SSL/TLS enabled, but hostname verification disabled. client = OpenSearch( hosts=[{'host': host, 'port': port}], http_compress=True, # enables gzip compression for request bodies # http_auth=auth, use_ssl=False, verify_certs=False, ssl_assert_hostname=False, ssl_show_warn=False, # ca_certs=ca_certs_path ) index_name = 'my-dsl-index' index_body = { 'settings': { 'index': { 'number_of_shards': 4 } } } response = client.indices.create(index_name, index_body) print(' Creating index:') print(response) # Create the structure of the document class Movie(Document): title = Text(fields={'raw': Keyword()}) director = Text() year = Text() class Index: name = index_name def save(self, ** kwargs): return super(Movie, self).save(** kwargs) # Set up the opensearch-py version of the document Movie.init(using=client) doc = Movie(meta={'id': 1}, title='Moneyball', director='Bennett Miller', year='2011') response = doc.save(using=client) print(' Adding document:') print(response) # Perform bulk operations movies = '{ "index" : { "_index" : "my-dsl-index", "_id" : "2" } } \n { "title" : "Interstellar", "director" : "Christopher Nolan", "year" : "2014"} \n { "create" : { "_index" : "my-dsl-index", "_id" : "3" } } \n { "title" : "Star Trek Beyond", "director" : "Justin Lin", "year" : "2015"} \n { "update" : {"_id" : "3", "_index" : "my-dsl-index" } } \n { "doc" : {"year" : "2016"} }' client.bulk(movies) # Search for the document. s = Search(using=client, index=index_name) \ .filter('term', year='2011') \ .query('match', title='Moneyball') response = s.execute() print(' Search results:') for hit in response: print(hit.meta.score, hit.title) # Delete the document. print(' Deleting document:') print(response) # Delete the index. response = client.indices.delete( index = index_name ) print(' Deleting index:') print(response) ``` -------------------------------- ### Start OpenSearch Cluster with Docker Source: https://github.com/opensearch-project/documentation-website/blob/main/_ai-agent-integrations/agent-skills.md If no OpenSearch cluster is found, this script starts one using Docker. Ensure Docker is installed and running. ```bash bash scripts/start_opensearch.sh ``` -------------------------------- ### Start OpenSearch Service Source: https://github.com/opensearch-project/documentation-website/blob/main/_install-and-configure/install-opensearch/tar.md Navigate to the OpenSearch bin directory and start the service in the foreground. Ensure OpenSearch is running before applying configuration changes. ```bash # Change directories cd /path/to/opensearch-{{site.opensearch_version}}/bin # Run the service in the foreground ./opensearch ``` -------------------------------- ### Regexp Query Example Source: https://github.com/opensearch-project/documentation-website/blob/main/_query-dsl/term/regexp.md This example demonstrates a basic `regexp` query to find terms starting with an uppercase or lowercase letter followed by 'amlet'. ```APIDOC ## GET shakespeare/_search ### Description Searches for terms matching a regular expression. ### Query ```json { "query": { "regexp": { "play_name": "[a-zA-Z]amlet" } } } ``` ``` -------------------------------- ### Run a Sample SQL Command Source: https://github.com/opensearch-project/documentation-website/blob/main/_sql-and-ppl/cli.md Execute a sample SQL query using the CLI. To display more than the default 200 rows, use a LIMIT clause. ```sql SELECT * FROM accounts; ``` -------------------------------- ### Install OpenSearch Plugins Source: https://github.com/opensearch-project/documentation-website/blob/main/_install-and-configure/install-opensearch/operator/operator-opensearch-config.md Add plugins to the `general.pluginsList` to have the operator install them during OpenSearch setup. Supports plugin names or URLs to ZIP files. ```yaml general: version: 3.0.0 httpPort: 9200 vendor: opensearch serviceName: my-cluster pluginsList: [ "repository-s3", "https://github.com/opensearch-project/opensearch-prometheus-exporter/releases/download/3.0.0.0/prometheus-exporter-3.0.0.0.zip", ] ``` -------------------------------- ### Dockerfile for HDFS Plugin Installation Source: https://github.com/opensearch-project/documentation-website/blob/main/_tuning-your-cluster/availability-and-recovery/snapshots/snapshot-restore.md Example Dockerfile snippet to install the repository-hdfs plugin during image build. Ensure the OpenSearch version is correctly specified. ```dockerfile FROM opensearchproject/opensearch:{{site.opensearch_version}} RUN /usr/share/opensearch/bin/opensearch-plugin install --batch repository-hdfs ``` -------------------------------- ### Start OpenSearch Benchmark daemon on nodes Source: https://github.com/opensearch-project/documentation-website/blob/main/_benchmark/user-guide/optimizing-benchmarks/distributed-load.md Initialize the benchmark daemon on each node, specifying the local node IP and the coordinator node IP. ```bash opensearch-benchmarkd start --node-ip=192.0.1.0 --coordinator-ip=192.0.1.0 ``` ```bash opensearch-benchmarkd start --node-ip=198.52.100.0 --coordinator-ip=192.0.1.0 ``` ```bash opensearch-benchmarkd start --node-ip=198.53.100.0 --coordinator-ip=192.0.1.0 ``` -------------------------------- ### POST /_example/endpoint/{path_parameter} Source: https://github.com/opensearch-project/documentation-website/blob/main/templates/API_TEMPLATE.md Performs an example operation with a path parameter and optional request body. ```APIDOC ## POST /_example/endpoint/{path_parameter} ### Description Performs an example operation with a path parameter and an optional request body. ### Method POST ### Endpoint /_example/endpoint/{path_parameter} ### Parameters #### Path Parameters - **path_parameter** (Type) - Example path parameter description. Default is ... Optional. #### Query Parameters - **query_parameter** (String) - Example query parameter description. Default is ... Optional. ### Request Body - **example_object** (Object) - Example object description. - **example_object.required_request_field** (Type) - Required request field description. Required. - **example_object.optional_request_field** (Type) - Optional request field description. Optional. Default is ... ### Request Example ```json POST /_example/endpoint/{path_parameter}?query_parameter=example_value { "example_object": { "required_request_field": "example value", "optional_request_field": "example value" } } ``` ### Response #### Success Response (200) - **_nodes** (Object) - Description of nodes. - **_nodes.total** (Number) - Total number of nodes. - **_nodes.successful** (Number) - Number of successful nodes. - **_nodes.failed** (Number) - Number of failed nodes. #### Response Example ```json { "_nodes" : { "total" : 1, "successful" : 1, "failed" : 0 } } ``` ### Required permissions If you use the Security plugin, make sure you have the appropriate permissions: `cluster:example/permission/name`. ``` -------------------------------- ### Get Threat Intelligence Source Configuration Source: https://github.com/opensearch-project/documentation-website/blob/main/_security-analytics/threat-intelligence/api/source.md Example GET request to retrieve the details of a specific threat intelligence source configuration using its ID. ```json GET /_plugins/_security_analytics/threat_intel/sources/{source-id} ``` ```json GET /_plugins/_security_analytics/threat_intel/sources/{source-id} ``` ```json { "_id": "a-jnfjkAF_uQjn8Weo4", "_version": 2, "source_config": { "name": "my_custom_feed_2", "format": "STIX2", "type": "S3_CUSTOM", "ioc_types": [ "ipv4_addr", "hashes" ], "description": "this is the description", "created_by_user": null, "created_at": "2024-06-27T00:52:56.373Z", "source": { "s3": { "bucket_name": "threat-intel-s3-test-bucket", "object_key": "bd", "region": "us-west-2", "role_arn": "arn:aws:iam::540654354201:role/threat_intel_s3_test_role" } }, "enabled": true, "enabled_time": "2024-06-27T00:52:56.373Z", "last_update_time": "2024-06-27T00:52:57.824Z", "schedule": { "interval": { "start_time": 1717097122, "period": 1, "unit": "Days" } }, "state": "AVAILABLE", "refresh_type": "FULL", "last_refreshed_user": null, "last_refreshed_time": "2024-06-27T00:52:56.533Z" } } ``` -------------------------------- ### Get Snapshot Status Example Source: https://github.com/opensearch-project/documentation-website/blob/main/_api-reference/snapshots/get-snapshot-status.md An example of the response received when querying the status of a snapshot. This response details the state of shards and statistics for various indices. ```APIDOC ## GET /_snapshot///_status ### Description Retrieves the status of a snapshot operation, including details about shard statistics and data size for each index included in the snapshot. ### Method GET ### Endpoint /_snapshot///_status ### Parameters #### Path Parameters - **repository** (string) - Required - The name of the repository where the snapshot is stored. - **snapshot** (string) - Required - The name of the snapshot. ### Response #### Success Response (200) - **indices** (object) - Contains statistics for each index included in the snapshot. - **index_name** (object) - Statistics for a specific index. - **shards_stats** (object) - Summary statistics for all shards of the index. - **initializing** (integer) - Number of shards currently initializing. - **started** (integer) - Number of shards currently started. - **finalizing** (integer) - Number of shards currently finalizing. - **done** (integer) - Number of shards that have completed successfully. - **failed** (integer) - Number of shards that failed. - **total** (integer) - Total number of shards for the index. - **stats** (object) - Overall statistics for the index. - **incremental** (object) - Statistics related to incremental data. - **file_count** (integer) - Number of files in the incremental snapshot. - **size_in_bytes** (integer) - Size of the incremental data in bytes. - **total** (object) - Total statistics for the index. - **file_count** (integer) - Total number of files in the snapshot for this index. - **size_in_bytes** (integer) - Total size of the data in bytes for this index. - **start_time_in_millis** (integer) - Timestamp when the snapshot process started for this index, in milliseconds since the epoch. - **time_in_millis** (integer) - Total time taken for the snapshot operation on this index, in milliseconds. - **shards** (object) - Detailed statistics for each individual shard of the index. - **shard_id** (object) - Statistics for a specific shard. - **stage** (string) - The current stage of the shard snapshot (e.g., DONE, FAILED). - **stats** (object) - Statistics for the shard, similar to the index `stats` object. - **incremental** (object) - Incremental statistics for the shard. - **file_count** (integer) - Number of files in the incremental snapshot for this shard. - **size_in_bytes** (integer) - Size of the incremental data in bytes for this shard. - **total** (object) - Total statistics for the shard. - **file_count** (integer) - Total number of files in the snapshot for this shard. - **size_in_bytes** (integer) - Total size of the data in bytes for this shard. - **start_time_in_millis** (integer) - Timestamp when the snapshot process started for this shard, in milliseconds since the epoch. - **time_in_millis** (integer) - Total time taken for the snapshot operation on this shard, in milliseconds. #### Response Example ```json { "indices": { ".opendistro-reports-definitions": { "shards_stats": { "initializing": 0, "started": 0, "finalizing": 0, "done": 1, "failed": 0, "total": 1 }, "stats": { "incremental": { "file_count": 1, "size_in_bytes": 208 }, "total": { "file_count": 1, "size_in_bytes": 208 }, "start_time_in_millis": 1660666843076, "time_in_millis": 200 }, "shards": { "0": { "stage": "DONE", "stats": { "incremental": { "file_count": 1, "size_in_bytes": 208 }, "total": { "file_count": 1, "size_in_bytes": 208 }, "start_time_in_millis": 1660666843076, "time_in_millis": 200 } } } }, ".opendistro-reports-instances": { "shards_stats": { "initializing": 0, "started": 0, "finalizing": 0, "done": 1, "failed": 0, "total": 1 }, "stats": { "incremental": { "file_count": 1, "size_in_bytes": 208 }, "total": { "file_count": 1, "size_in_bytes": 208 }, "start_time_in_millis": 1660666841667, "time_in_millis": 201 }, "shards": { "0": { "stage": "DONE", "stats": { "incremental": { "file_count": 1, "size_in_bytes": 208 }, "total": { "file_count": 1, "size_in_bytes": 208 }, "start_time_in_millis": 1660666841667, "time_in_millis": 201 } } } }, ".kibana_1": { "shards_stats": { "initializing": 0, "started": 0, "finalizing": 0, "done": 1, "failed": 0, "total": 1 }, "stats": { "incremental": { "file_count": 13, "size_in_bytes": 45733 }, "total": { "file_count": 13, "size_in_bytes": 45733 }, "start_time_in_millis": 1660666842673, "time_in_millis": 2007 }, "shards": { "0": { "stage": "DONE", "stats": { "incremental": { "file_count": 13, "size_in_bytes": 45733 }, "total": { "file_count": 13, "size_in_bytes": 45733 }, "start_time_in_millis": 1660666842673, "time_in_millis": 2007 } } } }, ".opensearch-notifications-config": { "shards_stats": { "initializing": 0, "started": 0, "finalizing": 0, "done": 1, "failed": 0, "total": 1 }, "stats": { "incremental": { "file_count": 1, "size_in_bytes": 208 }, "total": { "file_count": 1, "size_in_bytes": 208 }, "start_time_in_millis": 1660666842270, "time_in_millis": 200 }, "shards": { "0": { "stage": "DONE", "stats": { "incremental": { "file_count": 1, "size_in_bytes": 208 }, "total": { "file_count": 1, "size_in_bytes": 208 }, "start_time_in_millis": 1660666842270, "time_in_millis": 200 } } } } } } ``` ``` -------------------------------- ### Example Response: OpenSearch Dashboards Version Source: https://github.com/opensearch-project/documentation-website/blob/main/_migrate-or-upgrade/rolling-upgrade/rolling-upgrade-lab.md This is an example of the output from checking the manifest.yml file, displaying the schema version and the OpenSearch Dashboards build version. ```bash --- schema-version: '1.1' build: name: OpenSearch Dashboards version: 2.5.0 ``` -------------------------------- ### Start Docker Compose Source: https://github.com/opensearch-project/documentation-website/blob/main/_security/authentication-backends/saml.md Initiate the OpenSearch, OpenSearch Dashboards, and SAML server nodes using Docker Compose. ```zsh docker compose up. ``` -------------------------------- ### Get Destination Response Source: https://github.com/opensearch-project/documentation-website/blob/main/_observing-your-data/alerting/api.md Example response for a single destination retrieval. ```json { "totalDestinations": 1, "destinations": [{ "id": "1a2a3a4a5a6a7a", "type": "slack", "name": "sample-destination", "user": { "name": "psantos", "backend_roles": [ "human-resources" ], "roles": [ "alerting_full_access", "hr-role" ], "custom_attribute_names": [] }, "schema_version": 3, "seq_no": 0, "primary_term": 6, "last_update_time": 1603943261722, "slack": { "url": "https://example.com" } } ] } ``` -------------------------------- ### Build with Docker Source: https://github.com/opensearch-project/documentation-website/blob/main/CONTRIBUTING.md Start the development environment using Docker Compose. ```bash docker compose -f docker-compose.dev.yml up ``` -------------------------------- ### Install OpenSearch with Disabled Demo Configuration (3.7+) Source: https://github.com/opensearch-project/documentation-website/blob/main/_install-and-configure/install-opensearch/rpm.md Install OpenSearch using yum, disabling the demo security configuration. Use this for manual security setup. ```bash sudo env DISABLE_INSTALL_DEMO_CONFIG=true yum install opensearch-{{site.opensearch_version}}-linux-x64.rpm ```