### Install a Single Plugin Source: https://docs.opensearch.org/3.5/opensearch/install/plugins Installs a single plugin from a Maven repository. This example shows the interactive prompt for additional permissions. ```bash $ 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 Response for Get Settings Source: https://docs.opensearch.org/3.5/api-reference/index-apis/get-settings This is an example of the JSON response you can expect when retrieving settings for 'sample-index1', showing index creation date, shard count, replica count, and version information. ```json { "sample-index1": { "settings": { "index": { "creation_date": "1622672553417", "number_of_shards": "1", "number_of_replicas": "1", "uuid": "GMEA0_TkSaamrnJSzNLzwg", "version": { "created": "135217827", "upgraded": "135238227" }, "provided_name": "sample-index1" } } } } ``` -------------------------------- ### Service Map Processor Configuration Example Source: https://docs.opensearch.org/3.5/data-prepper/pipelines/configuration/processors/service-map This example demonstrates how to configure the `service_map` processor within a Data Prepper pipeline. It shows the setup for both a raw pipeline and a service-map-specific pipeline, including source, processor, and sink configurations. ```yaml entry-pipeline: source: otel_trace_source: path: "/test/path" sink: - pipeline: name: "raw-pipeline" - pipeline: name: "service-map-pipeline" raw-pipeline: source: pipeline: name: "entry-pipeline" processor: - otel_trace_raw: sink: - opensearch: hosts: [] index_type: trace-analytics-raw service-map-pipeline: source: pipeline: name: "entry-pipeline" processor: - service_map_stateful: window_duration: 60s sink: - opensearch: hosts: [] index_type: trace-analytics-service-map ``` -------------------------------- ### Install RPM Package with Demo Configuration Source: https://docs.opensearch.org/3.5/security/configuration/demo-configuration Use this command to install the OpenSearch RPM package, which includes the demo configuration setup. For versions 2.12+, the custom admin password must be set. ```bash sudo yum install opensearch-3.5.0-linux-x64.rpm ``` -------------------------------- ### Verify OpenSearch Installation with cURL Source: https://docs.opensearch.org/3.5/dashboards/install/helm Before installing OpenSearch Dashboards, ensure OpenSearch is running and accessible by sending a GET request to its API endpoint. This verifies your OpenSearch setup and connection. ```bash $ curl -XGET https://localhost:9200 -u 'admin:' --insecure { "name" : "opensearch-cluster-master-0", "cluster_name" : "opensearch-cluster", "cluster_uuid" : "72e_wDs1QdWHmwum_E2feA", "version" : { "distribution" : "opensearch", "number" : "3.1.0", "build_type" : "tar", "build_hash" : "8ff7c6ee924a49f0f59f80a6e1c73073c8904214", "build_date" : "2025-06-21T08:05:50.445588571Z", "build_snapshot" : false, "lucene_version" : "10.2.1", "minimum_wire_compatibility_version" : "2.19.0", "minimum_index_compatibility_version" : "2.0.0" }, "tagline" : "The OpenSearch Project: https://opensearch.org/" } ``` -------------------------------- ### Full OpenSearch Java Client Example Source: https://docs.opensearch.org/3.5/clients/java A comprehensive example demonstrating client initialization, index creation, settings update, document indexing, searching, deleting a document, and deleting the index. Includes basic authentication and SSL configuration. ```java import org.apache.http.HttpHost; import org.apache.http.auth.AuthScope; import org.apache.http.auth.UsernamePasswordCredentials; import org.apache.http.client.CredentialsProvider; import org.apache.http.impl.client.BasicCredentialsProvider; import org.apache.http.impl.nio.client.HttpAsyncClientBuilder; import org.opensearch.client.RestClient; import org.opensearch.client.RestClientBuilder; import org.opensearch.client.base.RestClientTransport; import org.opensearch.client.base.Transport; import org.opensearch.client.json.jackson.JacksonJsonpMapper; import org.opensearch.client.opensearch.OpenSearchClient; import org.opensearch.client.opensearch._global.IndexRequest; import org.opensearch.client.opensearch._global.IndexResponse; import org.opensearch.client.opensearch._global.SearchResponse; import org.opensearch.client.opensearch.indices.*; import org.opensearch.client.opensearch.indices.put_settings.IndexSettingsBody; import java.io.IOException; public class OpenSearchClientExample { public static void main(String[] args) { RestClient restClient = null; try{ System.setProperty("javax.net.ssl.trustStore", "/full/path/to/keystore"); System.setProperty("javax.net.ssl.trustStorePassword", "password-to-keystore"); //Only for demo purposes. Don't specify your credentials in code. final CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials("admin", "admin")); //Initialize the client with SSL and TLS enabled restClient = RestClient.builder(new HttpHost("localhost", 9200, "https")). setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() { @Override public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) { return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider); } }).build(); Transport transport = new RestClientTransport(restClient, new JacksonJsonpMapper()); OpenSearchClient client = new OpenSearchClient(transport); //Create the index String index = "sample-index"; CreateIndexRequest createIndexRequest = new CreateIndexRequest.Builder().index(index).build(); client.indices().create(createIndexRequest); //Add some settings to the index IndexSettings indexSettings = new IndexSettings.Builder().autoExpandReplicas("0-all").build(); IndexSettingsBody settingsBody = new IndexSettingsBody.Builder().settings(indexSettings).build(); PutSettingsRequest putSettingsRequest = new PutSettingsRequest.Builder().index(index).value(settingsBody).build(); client.indices().putSettings(putSettingsRequest); //Index some data IndexData indexData = new IndexData("first_name", "Bruce"); IndexRequest indexRequest = new IndexRequest.Builder().index(index).id("1").document(indexData).build(); client.index(indexRequest); //Search for the document SearchResponse searchResponse = client.search(s -> s.index(index), IndexData.class); for (int i = 0; i< searchResponse.hits().hits().size(); i++) { System.out.println(searchResponse.hits().hits().get(i).source()); } //Delete the document client.delete(b -> b.index(index).id("1")); // Delete the index DeleteIndexRequest deleteIndexRequest = new DeleteRequest.Builder().index(index).build(); DeleteIndexResponse deleteIndexResponse = client.indices().delete(deleteIndexRequest); } catch (IOException e){ System.out.println(e.toString()); } finally { try { if (restClient != null) { restClient.close(); } } catch (IOException e) { System.out.println(e.toString()); } } } } ``` -------------------------------- ### Get Detector API Request Example Source: https://docs.opensearch.org/3.5/security-analytics/api-tools/detector-api Example of a GET request to the Get Detector API, where `` should be replaced with the actual detector ID. ```http GET /_plugins/_security_analytics/detectors/ ``` -------------------------------- ### Sample Program: Full Workflow Source: https://docs.opensearch.org/3.5/clients/python-low-level A comprehensive sample program demonstrating the entire workflow: client creation with SSL/TLS, index creation, document indexing, bulk operations, searching, document deletion, and index deletion. ```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) ``` -------------------------------- ### Initialize OpenSearch Client Source: https://docs.opensearch.org/3.5/clients/php Sets up the OpenSearch client with connection details, authentication, and SSL verification settings. Use 'verify' => false for local development. ```php client = (new \OpenSearch\GuzzleClientFactory())->create([ 'base_uri' => 'https://localhost:9200', 'auth' => ['admin', getenv('OPENSEARCH_PASSWORD')], 'verify' => false, // Disables SSL verification for local development. ]); } // Create an index with non-default settings. public function createIndex() { $this->client->indices()->create([ 'index' => INDEX_NAME, 'body' => [ 'settings' => [ 'index' => [ 'number_of_shards' => 4 ] ] ] ]); } public function info() { // Print OpenSearch version information on console. var_dump($this->client->info()); } // Create a document public function create() { $time = time(); $this->existingID = $time; $this->deleteID = $time . '_uniq'; // Create a document passing the id $this->client->create([ 'id' => $time, 'index' => INDEX_NAME, 'body' => $this->getData($time) ]); // Create a document passing the id $this->client->create([ 'id' => $this->deleteID, 'index' => INDEX_NAME, 'body' => $this->getData($time) ]); // Create a document without passing the id (will be generated automatically) $this->client->create([ 'index' => INDEX_NAME, 'body' => $this->getData($time + 1) ]); //This should throw an exception because ID already exists // $this->client->create([ // 'id' => $this->existingID, // 'index' => INDEX_NAME, // 'body' => $this->getData($this->existingID) // ]); } public function update() { $this->client->update([ 'id' => $this->existingID, 'index' => INDEX_NAME, 'body' => [ //data must be wrapped in 'doc' object 'doc' => ['name' => 'updated'] ] ]); } public function bulk() { $bulkData = []; $time = time(); for ($i = 0; $i < 20; $i++) { $id = ($time + $i) . rand(10, 200); $bulkData[] = [ 'index' => [ '_index' => INDEX_NAME, '_id' => $id, ] ]; $this->bulkIds[] = $id; $bulkData[] = $this->getData($time + $i); } //will not throw exception! check $response for error $response = $this->client->bulk([ //default index 'index' => INDEX_NAME, 'body' => $bulkData ]); //give elastic a little time to create before update sleep(2); // bulk update for ($i = 0; $i < 15; $i++) { $bulkData[] = [ 'update' => [ '_index' => INDEX_NAME, '_id' => $this->bulkIds[$i], ] ]; $bulkData[] = [ 'doc' => [ 'name' => 'bulk updated' ] ]; } //will not throw exception! check $response for error $response = $this->client->bulk([ //default index 'index' => INDEX_NAME, 'body' => $bulkData ]); } public function deleteByQuery(string $query) { if ($query == '') { return; } $this->client->deleteByQuery([ 'index' => INDEX_NAME, 'q' => $query ]); } // Delete a single document public function deleteByID() { $this->client->delete([ 'id' => $this->deleteID, 'index' => INDEX_NAME, ]); } public function search() { $docs = $this->client->search([ //index to search in or '_all' for all indices 'index' => INDEX_NAME, 'size' => 1000, 'body' => [ 'query' => [ 'prefix' => [ 'name' => 'wrecking' ] ] ] ]); var_dump($docs['hits']['total']['value'] > 0); // Search for it $docs = $this->client->search([ 'index' => INDEX_NAME, 'body' => [ 'size' => 5, 'query' => [ ``` -------------------------------- ### Example GET Response Source: https://docs.opensearch.org/3.5/security/access-control/api This is an example response from a GET request to the audit API, showing the structure of the audit and compliance configurations. ```json { "_readonly" : [ "/audit/exclude_sensitive_headers", "/compliance/internal_config", "/compliance/external_config" ], "config" : { "compliance" : { "enabled" : true, "write_log_diffs" : false, "read_watched_fields" : { }, "read_ignore_users" : [ ], "write_watched_indices" : [ ], "write_ignore_users" : [ ], "read_metadata_only" : true, "write_metadata_only" : true, "external_config" : false, "internal_config" : true }, "enabled" : true, "audit" : { "ignore_users" : [ ], "ignore_requests" : [ ], "disabled_rest_categories" : [ "AUTHENTICATED", "GRANTED_PRIVILEGES" ], "disabled_transport_categories" : [ "AUTHENTICATED", "GRANTED_PRIVILEGES" ], "log_request_body" : true, "resolve_indices" : true, "resolve_bulk_requests" : true, "exclude_sensitive_headers" : true, "enable_transport" : true, "enable_rest" : true } } } ``` -------------------------------- ### Full Program: OpenSearch Client Operations Source: https://docs.opensearch.org/3.5/clients/python-high-level A comprehensive example demonstrating client initialization with SSL/TLS settings, index creation, document insertion, bulk operations, searching, and cleanup (deleting document and index). ```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" } } { "title" : "Interstellar", "director" : "Christopher Nolan", "year" : "2014"} { "create" : { "_index" : "my-dsl-index", "_id" : "3" } } { "title" : "Star Trek Beyond", "director" : "Justin Lin", "year" : "2015"} { "update" : {"_id" : "3", "_index" : "my-dsl-index" } } { "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) ``` -------------------------------- ### Example Get Model Request Source: https://docs.opensearch.org/3.5/ml-commons-plugin/api/model-apis/get-model An example of a GET request to retrieve a specific model's details using its ID. ```bash GET /_plugins/_ml/models/N8AE1osB0jLkkocYjz7D ``` -------------------------------- ### Display Help Information Source: https://docs.opensearch.org/3.5/benchmark/installing-benchmark After installation, use this command to display the help information for OpenSearch Benchmark, showing available commands and options. ```bash opensearch-benchmark -h ``` -------------------------------- ### Example Request for Get Message Traces Source: https://docs.opensearch.org/3.5/ml-commons-plugin/api/memory-apis/get-message-traces An example of how to call the Get Message Traces API with a specific message ID. ```http GET /_plugins/_ml/memory/message/TAuCZY0BT2tRrkdmCPqZ/traces ``` -------------------------------- ### Example Request to Get Controller Source: https://docs.opensearch.org/3.5/ml-commons-plugin/api/controller-apis/get-controller An example of how to make a GET request to retrieve the controller details for a specific model ID. ```http GET /_plugins/_ml/controllers/T_S-cY0BKCJ3ot9qr0aP ``` -------------------------------- ### Apply All Configurations from Directory (Shorthand) Source: https://docs.opensearch.org/3.5/security/configuration/security-admin A concise way to apply all security configurations from a directory, including keystore and truststore parameters. This is a common use case for deploying a full security setup. ```bash ./securityadmin.sh -cd ../../../config/opensearch-security -ts ... -tspass ... -ks ... -kspass ... ``` -------------------------------- ### Example Request to Get Memory Container Source: https://docs.opensearch.org/3.5/ml-commons-plugin/api/agentic-memory-apis/get-memory-container An example of an HTTP GET request to retrieve a specific memory container using its ID. ```http GET /_plugins/_ml/memory_containers/SdjmmpgBOh0h20Y9kWuN ``` -------------------------------- ### Run OpenSearch Windows Install Script Source: https://docs.opensearch.org/3.5/install-and-configure/install-opensearch/windows Execute the OpenSearch Windows installation batch script to start the installation process. ```batch .\opensearch-windows-install.bat ``` -------------------------------- ### Start OpenSearch Dashboards Service Source: https://docs.opensearch.org/3.5/install-and-configure/install-dashboards/rpm Start the OpenSearch Dashboards service after installation or enabling. ```bash sudo systemctl start opensearch-dashboards ``` -------------------------------- ### Create Sample Index Source: https://docs.opensearch.org/3.5/api-reference/cluster-api/cluster-reroute Use this command to set up a sample index with one shard and one replica for testing reroute operations. ```json PUT /test-cluster-index { "settings": { "number_of_shards": 1, "number_of_replicas": 1 } } ``` -------------------------------- ### Example output of metadata migrate help command Source: https://docs.opensearch.org/3.5/migration-assistant/migration-phases/migrate-metadata This is an example of the response you should receive when running the `console -v metadata migrate --help` command, showing logging information and the metadata migration command. ```bash (.venv) bash-5.2# console -v metadata migrate --help INFO:console_link.cli:Logging set to INFO . . . INFO:console_link.models.metadata:Migrating metadata with command: /root/metadataMigration/bin/MetadataMigration --otel-collector-endpoint http://otel-collector:4317 migrate --snapshot-name snapshot_2023_01_01 --target-host https://opensearchtarget:9200 --min-replicas 0 --file-system-repo-path /snapshot/test-console --target-username admin --target-password ******** --target-insecure --help . . . ``` -------------------------------- ### Example Agent Retrieval Request Source: https://docs.opensearch.org/3.5/ml-commons-plugin/api/agent-apis/get-agent An example of a GET request to retrieve an agent using its ID. ```http GET /_plugins/_ml/agents/N8AE1osB0jLkkocYjz7D ``` -------------------------------- ### Example Workflow Retrieval Request Source: https://docs.opensearch.org/3.5/automating-configurations/api/get-workflow An example of a GET request to retrieve a specific workflow by its ID. ```http GET /_plugins/_flow_framework/workflow/8xL8bowB8y25Tqfenm50 ``` -------------------------------- ### Complete Sample Program with OpenSearch Ruby Client Source: https://docs.opensearch.org/3.5/clients/ruby This comprehensive example showcases index creation, mapping, document indexing, updating, bulk operations, searching, and deletion. It uses `MultiJson.dump` for pretty-printing responses. Ensure the OpenSearch client is initialized and connected to the correct host. ```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") # Bulk several operations together actions = [ { index: { _index: index_name, _id: 100, data: { first_name: 'Paulo', last_name: 'Santos', gpa: 3.29, grad_year: 2022 } } }, { index: { _index: index_name, _id: 200, data: { first_name: 'Shirley', last_name: 'Rodriguez', gpa: 3.92, grad_year: 2020 } } }, { index: { _index: index_name, _id: 300, data: { first_name: 'Akua', last_name: 'Mansa', gpa: 3.95, grad_year: 2022 } } }, { index: { _index: index_name, _id: 400, data: { first_name: 'John', last_name: 'Stiles', gpa: 3.72, grad_year: 2019 } } }, { index: { _index: index_name, _id: 500, data: { first_name: 'Li', last_name: 'Juan', gpa: 3.94, grad_year: 2022 } } }, { index: { _index: index_name, _id: 600, data: { first_name: 'Richard', last_name: 'Roe', gpa: 3.04, grad_year: 2020 } } }, { update: { _index: index_name, _id: 100, data: { doc: { gpa: 3.73 } } } }, { delete: { _index: index_name, _id: 200 } } ] client.bulk(body: actions, refresh: true) puts 'All documents in the index after bulk operations with scrolling:' response = client.search(index: index_name, scroll: '2m', size: 2) while response['hits']['hits'].size.positive? scroll_id = response['_scroll_id'] puts(response['hits']['hits'].map { |doc| [doc['_source']['first_name'] + ' ' + doc['_source']['last_name']] }) response = client.scroll(scroll: '1m', body: { scroll_id: scroll_id }) end # Multi search actions = [ {}, {query: {range: {gpa: {gt: 3.9}}}}, {}, {query: {range: {gpa: {lt: 3.1}}}} ] response = client.msearch(index: index_name, body: actions) puts 'Multi search results:' puts MultiJson.dump(response, pretty: "true") ``` -------------------------------- ### Install opensearch-dsl Source: https://docs.opensearch.org/3.5/clients/python-high-level Install the high-level Python client using pip. This is the first step to adding the client to your project. ```bash pip install opensearch-dsl ``` -------------------------------- ### Traffic Replayer Start Output Source: https://docs.opensearch.org/3.5/migration-assistant/migration-phases/replay-captured-traffic This is an example of the output you should expect when successfully starting the Traffic Replayer. ```bash root@ip-10-0-2-66:~# console replay start Replayer started successfully. Service migration-dev-traffic-replayer-default set to 1 desired count. Currently 0 running and 0 pending. ``` -------------------------------- ### Example workload.json Configuration Source: https://docs.opensearch.org/3.5/benchmark/user-guide/understanding-workloads/anatomy-of-a-workload This example demonstrates the essential elements for creating a workload.json file, including index definitions, corpora, and a schedule of operations. ```json { "description": "Tutorial benchmark for OpenSearch Benchmark", "indices": [ { "name": "movies", "body": "index.json" } ], "corpora": [ { "name": "movies", "documents": [ { "source-file": "movies-documents.json", "document-count": 11658903, # Fetch document count from command line "uncompressed-bytes": 1544799789 # Fetch uncompressed bytes from command line } ] } ], "schedule": [ { "operation": { "operation-type": "create-index" } }, { "operation": { "operation-type": "cluster-health", "request-params": { "wait_for_status": "green" }, "retry-until-success": true } }, { "operation": { "operation-type": "bulk", "bulk-size": 5000 }, "warmup-time-period": 120, "clients": 8 }, { "operation": { "name": "query-match-all", "operation-type": "search", "body": { "query": { "match_all": {} } } }, "iterations": 1000, "target-throughput": 100 } ] } ``` -------------------------------- ### Example Response for Get Script Languages Source: https://docs.opensearch.org/3.5/api-reference/script-apis/get-script-language This is an example of the JSON response you will receive when calling the Get Script Languages API. It details the allowed script types and lists each supported language along with its associated contexts. ```json { "types_allowed" : [ "inline", "stored" ], "language_contexts" : [ { "language" : "expression", "contexts" : [ "aggregation_selector", "aggs", "bucket_aggregation", "field", "filter", "number_sort", "score", "terms_set" ] }, { "language" : "mustache", "contexts" : [ "template" ] }, { "language" : "opensearch_query_expression", "contexts" : [ "aggs", "filter" ] }, { "language" : "painless", "contexts" : [ "aggregation_selector", "aggs", "aggs_combine", "aggs_init", "aggs_map", "aggs_reduce", "analysis", "bucket_aggregation", "field", "filter", "ingest", "interval", "moving-function", "number_sort", "painless_test", "processor_conditional", "score", "script_heuristic", "similarity", "similarity_weight", "string_sort", "template", "terms_set", "trigger", "update" ] } ] } ``` -------------------------------- ### Create Deployment Directory and Navigate Source: https://docs.opensearch.org/3.5/migrate-or-upgrade/rolling-upgrade/rolling-upgrade-lab Create a new directory named 'deploy' in your home directory and change into it. This directory will be used for deployment scripts, configuration files, and TLS certificates. ```bash mkdir ~/deploy && cd ~/deploy ``` -------------------------------- ### HDFS Plugin Installation in Dockerfile Source: https://docs.opensearch.org/3.5/tuning-your-cluster/availability-and-recovery/snapshots/snapshot-restore Example Dockerfile snippet for installing the repository-hdfs plugin during image build. ```dockerfile FROM opensearchproject/opensearch:3.5.0 RUN /usr/share/opensearch/bin/opensearch-plugin install --batch repository-hdfs ``` -------------------------------- ### Complete Sample Program with OpenSearch .NET Client Source: https://docs.opensearch.org/3.5/clients/OSC-dot-net This program demonstrates indexing a single student, searching for a student by last name, searching using the low-level client, and indexing an array of students. Ensure the OpenSearch.Client NuGet package is installed. ```csharp using OpenSearch.Client; using OpenSearch.Net; namespace NetClientProgram; internal class Program { private static IOpenSearchClient osClient = new OpenSearchClient(); public static void Main(string[] args) { Console.WriteLine("Indexing one student......"); var student = new Student { Id = 100, FirstName = "Paulo", LastName = "Santos", Gpa = 3.93, GradYear = 2021 }; var response = osClient.Index(student, i => i.Index("students")); Console.WriteLine(response.IsValid ? "Response received" : "Error"); Console.WriteLine("Searching for one student......"); SearchForOneStudent(); Console.WriteLine("Searching using low-level client......"); SearchLowLevel(); Console.WriteLine("Indexing an array of Student objects......"); var studentArray = new Student[] { new() { Id = 200, FirstName = "Shirley", LastName = "Rodriguez", Gpa = 3.91, GradYear = 2019}, new() { Id = 300, FirstName = "Nikki", LastName = "Wolf", Gpa = 3.87, GradYear = 2020} }; var manyResponse = osClient.IndexMany(studentArray, "students"); Console.WriteLine(manyResponse.IsValid ? "Response received" : "Error"); } private static void SearchForOneStudent() { var searchResponse = osClient.Search(s => s .Index("students") .Query(q => q .Match(m => m .Field(fld => fld.LastName) .Query("Santos")))); PrintResponse(searchResponse); } private static void SearchForAllStudentsWithANonEmptyLastName() { var searchResponse = osClient.Search(s => s .Index("students") .Query(q => q .Bool(b => b .Must(m => m.Exists(fld => fld.LastName)) .MustNot(m => m.Term(t => t.Verbatim().Field(fld => fld.LastName).Value(string.Empty))) ))) PrintResponse(searchResponse); } private static void SearchLowLevel() { // Search for the student using the low-level client var lowLevelClient = osClient.LowLevel; var searchResponseLow = lowLevelClient.Search> ("students", PostData.Serializable( new { query = new { match = new { lastName = new { query = "Santos" } } } })); PrintResponse(searchResponseLow); } private static void PrintResponse(ISearchResponse response) { if (response.IsValid) { foreach (var s in response.Documents) { Console.WriteLine($"{s.Id} {s.LastName} " + $"{s.FirstName} {s.Gpa} {s.GradYear}"); } } else { Console.WriteLine("Student not found."); } } } ``` -------------------------------- ### Wildcard Query Example Source: https://docs.opensearch.org/3.5/query-dsl/term/wildcard This example demonstrates a case-sensitive wildcard query to find terms starting with 'H' and ending with 'Y' in the 'speaker' field. ```APIDOC ## GET shakespeare/_search ### Description Searches for terms in the 'speaker' field that match the pattern 'H*Y' in a case-sensitive manner. ### Method GET ### Endpoint shakespeare/_search ### Query Parameters None ### Request Body ```json { "query": { "wildcard": { "speaker": { "value": "H*Y", "case_insensitive": false } } } } ``` ### Response #### Success Response (200) - **_index** (string) - The name of the index. - **_type** (string) - The type of the document. - **_id** (string) - The ID of the document. - **_score** (float) - The relevance score of the document. - **_source** (object) - The source fields of the document. #### Response Example ```json { "took": 10, "timed_out": false, "_shards": { "total": 5, "successful": 5, "skipped": 0, "failed": 0 }, "hits": { "total": { "value": 1, "relation": "eq" }, "max_score": 1.0, "hits": [ { "_index": "shakespeare", "_type": "_doc", "_id": "some_id", "_score": 1.0, "_source": { "speaker": "Hamlet" } } ] } } ``` ``` -------------------------------- ### OpenSearch Node Initialization Log Example Source: https://docs.opensearch.org/3.5/migrate-or-upgrade/rolling-upgrade/rolling-upgrade-lab This is an example log entry indicating that an OpenSearch node has successfully initialized and is ready. ```log [INFO ][o.o.s.c.ConfigurationRepository] [os-node-01] Node 'os-node-01' initialized ``` -------------------------------- ### Logstash Plugin Installation Output Source: https://docs.opensearch.org/3.5/tools/logstash/index Example output indicating a successful installation of the logstash-output-opensearch plugin. This confirms the plugin is ready for use. ```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 ``` -------------------------------- ### Example Workspace Object Configuration Source: https://docs.opensearch.org/3.5/dashboards/workspace/workspace Illustrates a typical Workspace object configuration, demonstrating how to set the ID, name, description, and features for a workspace. ```json { id: "M5NqCu", name: "Analytics team", description: "Analytics team workspace", features: ["use-case-analytics"], } ``` -------------------------------- ### Basic Join Syntax Examples Source: https://docs.opensearch.org/3.5/sql-and-ppl/ppl/commands/join Demonstrates various ways to use the basic join command syntax, including different join types, join criteria (on/where), and aliasing. ```ppl source = table1 | inner join left = l right = r on l.a = r.a table2 | fields l.a, r.a, b, c ``` ```ppl source = table1 | inner join left = l right = r where l.a = r.a table2 | fields l.a, r.a, b, c ``` ```ppl source = table1 | left join left = l right = r on l.a = r.a table2 | fields l.a, r.a, b, c ``` ```ppl source = table1 | right join left = l right = r on l.a = r.a table2 | fields l.a, r.a, b, c ``` ```ppl source = table1 | full left = l right = r on l.a = r.a table2 | fields l.a, r.a, b, c ``` ```ppl source = table1 | cross join left = l right = r on 1=1 table2 ``` ```ppl source = table1 | left semi join left = l right = r on l.a = r.a table2 ``` ```ppl source = table1 | left anti join left = l right = r on l.a = r.a table2 ``` ```ppl source = table1 | join left = l right = r [ source = table2 | where d > 10 | head 5 ] ``` ```ppl source = table1 | inner join on table1.a = table2.a table2 | fields table1.a, table2.a, table1.b, table1.c ``` ```ppl source = table1 | inner join on a = c table2 | fields a, b, c, d ``` ```ppl source = table1 as t1 | join left = l right = r on l.a = r.a table2 as t2 | fields l.a, r.a ``` ```ppl source = table1 as t1 | join left = l right = r on l.a = r.a table2 as t2 | fields t1.a, t2.a ``` ```ppl source = table1 | join left = l right = r on l.a = r.a [ source = table2 ] as s | fields l.a, s.a ``` -------------------------------- ### Install HDFS Repository Plugin in Dockerfile Source: https://docs.opensearch.org/3.5/opensearch/snapshots/snapshot-restore Install the `repository-hdfs` plugin within a Dockerfile for OpenSearch. This ensures the plugin is available when the container starts. ```dockerfile FROM opensearchproject/opensearch:3.5.0 RUN /usr/share/opensearch/bin/opensearch-plugin install --batch repository-hdfs ``` -------------------------------- ### List Installed Plugins Source: https://docs.opensearch.org/3.5/api-reference/cat/cat-plugins Retrieves a list of all installed plugins in the OpenSearch cluster. This endpoint can be used to get a comprehensive overview of the plugin landscape. ```APIDOC ## GET /_cat/plugins ### Description Lists the names, components, and versions of the installed plugins. ### Method GET ### Endpoint /_cat/plugins ### Query Parameters #### Optional Query Parameters - **cluster_manager_timeout** (String) - The amount of time allowed to establish a connection to the cluster manager node. - **format** (String) - A short version of the `Accept` header, such as `json` or `yaml`. - **h** (List) - A comma-separated list of column names to display. - **help** (Boolean) - Returns help information. Defaults to `false`. - **local** (Boolean) - Returns local information but does not retrieve the state from the cluster manager node. Defaults to `false`. - **s** (List) - A comma-separated list of column names or column aliases to sort by. - **v** (Boolean) - Enables verbose mode, which displays column headers. Defaults to `false`. ### Request Example ``` GET /_cat/plugins?v ``` ### Response Columns - **id** (String) - The unique node identifier. - **name** (String) - The node name. - **component** (String) - The plugin component name. - **version** (String) - The plugin version. - **description** (String) - The plugin description and details. ### Example Response ``` name component version opensearch-node1 analysis-icu 3.3.2 opensearch-node1 opensearch-alerting 3.3.2.0 ``` ### Example Request with Specific Columns ``` GET /_cat/plugins?v&h=name,component,version ``` ```