Skip to content

Commit

Permalink
Added guide for using raw JSON REST requests with low-level client.
Browse files Browse the repository at this point in the history
Signed-off-by: Djcarrillo6 <[email protected]>

Added sample for using raw JSON REST requests with low-level client.

Signed-off-by: Djcarrillo6 <[email protected]>

Added sample for using raw JSON REST requests with low-level client #2

Signed-off-by: Djcarrillo6 <[email protected]>

Created new samples project & PR review changes.

Signed-off-by: Djcarrillo6 <[email protected]>

Aligned action examples with Python guide.

Signed-off-by: Djcarrillo6 <[email protected]>
  • Loading branch information
Djcarrillo6 committed Nov 3, 2023
1 parent b014ff4 commit 6e38e9f
Show file tree
Hide file tree
Showing 5 changed files with 168 additions and 0 deletions.
9 changes: 9 additions & 0 deletions OpenSearch.sln
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSearch.Stack.ArtifactsA
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{22DF419F-9A90-4317-957D-E239EB3F95DF}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{E89FE975-FA94-405F-B748-BF2EC8AFFEEE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Samples", "samples\Samples\Samples.csproj", "{0D084660-06BF-4F3A-A041-DAAB4837378F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -137,6 +141,7 @@ Global
{22DF419F-9A90-4317-957D-E239EB3F95DF} = {87ABA679-F3F4-48CE-82B3-1AAE5D0A5935}
{C80D225C-F072-4B24-9ACE-82EFD9362237} = {22DF419F-9A90-4317-957D-E239EB3F95DF}
{1F5A7B1A-2566-481F-91B5-A63D7F939973} = {22DF419F-9A90-4317-957D-E239EB3F95DF}
{0D084660-06BF-4F3A-A041-DAAB4837378F} = {E89FE975-FA94-405F-B748-BF2EC8AFFEEE}
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5B393962-7586-49BA-BD99-3B1E35F48E94}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
Expand Down Expand Up @@ -231,5 +236,9 @@ Global
{E7C0BDC2-28AD-4582-8FEA-0F6327A42C0E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E7C0BDC2-28AD-4582-8FEA-0F6327A42C0E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E7C0BDC2-28AD-4582-8FEA-0F6327A42C0E}.Release|Any CPU.Build.0 = Release|Any CPU
{0D084660-06BF-4F3A-A041-DAAB4837378F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0D084660-06BF-4F3A-A041-DAAB4837378F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0D084660-06BF-4F3A-A041-DAAB4837378F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0D084660-06BF-4F3A-A041-DAAB4837378F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
8 changes: 8 additions & 0 deletions USER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
- [OpenSearch.Net](#opensearchnet)
- [Getting Started](#getting-started-2)
- [Connecting](#connecting-2)
- [Advanced Features](#advanced-features)
- [Making Raw JSON Requests](guides/json.md)

# User Guide

This user guide specifies how to include and use the .NET client in your application.
Expand Down Expand Up @@ -303,3 +306,8 @@ var client = new OpenSearchLowLevelClient(config);
```

Note the main difference here is that we are instantiating an `OpenSearchLowLevelClient` rather than `OpenSearchClient`, and `ConnectionConfiguration` instead of `ConnectionSettings`.


## Advanced Features

- [Making Raw JSON Requests](guides/json.md)
69 changes: 69 additions & 0 deletions guides/json.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
- [Making Raw JSON REST Requests](#making-raw-json-rest-requests)
- [GET](#get)
- [PUT](#put)
- [POST](#post)
- [DELETE](#delete)

# Making Raw JSON REST Requests
OpenSearch exposes a REST API that you can use to interact with OpenSearch. The OpenSearch .NET client provides a low-level API that allows you to send raw JSON requests to OpenSearch. This API is useful if you want to use a feature that is not yet supported by the OpenSearch .NET client, but it supported by the OpenSearch REST API.

## GET
The following example returns the server version information via `GET /`.

```csharp
var versionResponse = await client.LowLevel.DoRequestAsync<DynamicResponse>(HttpMethod.GET, "/", CancellationToken.None);
Console.WriteLine(versionResponse.Body["version"]["distribution"].ToString(), versionResponse.Body["version"]["number"].ToString()); // Distribution & Version number
```

# PUT
The following example creates a document via `PUT /movies/_doc/{id}` with a request body that specifies the document to create.

```csharp
var indexBody = new
{
settings = new
{
index = new
{
number_of_shards = 4
}
}
};

var putResponse = await client.LowLevel.DoRequestAsync<DynamicResponse>(HttpMethod.PUT, "/movies", CancellationToken.None, PostData.Serializable(indexBody));
Console.WriteLine(putResponse.Body["acknowledged"].ToString()); // true
```

## POST
The following example creates a document via `POST /movies/_doc` with a request body that specifies the document to create.

```csharp
string q = "miller";

var query = new
{
size = 5,
query = new
{
multi_match = new
{
query = q,
fields = new[] { "title^2", "director" }
}
}
};

var postResponse = await client.LowLevel.DoRequestAsync<DynamicResponse>(HttpMethod.POST, "/movies/_search", CancellationToken.None, PostData.Serializable(query));
Console.WriteLine(postResponse.Body.ToString());
```

# DELETE
The following example deletes a document via `DELETE /movies/_doc/{id}`.

```csharp
var deleteResponse = await client.LowLevel.DoRequestAsync<DynamicResponse>(HttpMethod.DELETE, "/movies", CancellationToken.None);
Console.WriteLine(deleteResponse.Body["acknowledged"].ToString()); // true
```

# Sample Code
[Making Raw JSON Requests](/samples/Samples/Program.cs)
67 changes: 67 additions & 0 deletions samples/Samples/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

using OpenSearch.Client;

Check failure on line 8 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.1.0)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 8 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.1.0)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 8 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.2.1)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 8 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.2.1)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 8 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / compile

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 8 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / compile

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 8 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.6.0)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 8 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.6.0)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 8 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (1.1.0)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 8 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (1.1.0)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 8 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.5.0)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 8 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.5.0)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 8 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Canary

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 8 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Canary

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 8 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (1.2.4)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 8 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (1.2.4)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 8 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Unit

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 8 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Unit

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 8 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.0.1)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 8 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.0.1)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 8 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.7.0)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 8 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.7.0)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 8 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (1.3.11)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 8 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (1.3.11)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 8 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch Unreleased (1.x)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 8 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch Unreleased (1.x)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 8 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.4.1)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 8 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.4.1)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 8 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.9.0)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 8 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.9.0)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 8 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.3.0)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 8 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.3.0)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 8 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Create Release Artifacts

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 8 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Create Release Artifacts

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 8 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.8.0)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 8 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.8.0)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 8 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch Unreleased (main)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 8 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch Unreleased (main)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)
using OpenSearch.Net;

Check failure on line 9 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.1.0)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.1.0)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.2.1)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.2.1)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / compile

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / compile

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.6.0)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.6.0)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (1.1.0)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (1.1.0)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.5.0)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.5.0)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Canary

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Canary

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (1.2.4)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (1.2.4)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Unit

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Unit

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.0.1)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.0.1)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.7.0)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.7.0)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (1.3.11)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (1.3.11)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch Unreleased (1.x)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch Unreleased (1.x)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.4.1)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.4.1)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.9.0)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.9.0)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.3.0)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.3.0)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Create Release Artifacts

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Create Release Artifacts

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.8.0)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.8.0)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch Unreleased (main)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch Unreleased (main)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)
using HttpMethod = OpenSearch.Net.HttpMethod;

Check failure on line 10 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.1.0)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 10 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.1.0)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 10 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.2.1)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 10 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.2.1)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 10 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / compile

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 10 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / compile

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 10 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.6.0)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 10 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.6.0)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 10 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (1.1.0)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 10 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (1.1.0)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 10 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.5.0)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 10 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.5.0)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 10 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Canary

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 10 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Canary

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 10 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (1.2.4)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 10 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (1.2.4)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 10 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Unit

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 10 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Unit

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 10 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.0.1)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 10 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.0.1)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 10 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.7.0)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 10 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.7.0)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 10 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (1.3.11)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 10 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (1.3.11)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 10 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch Unreleased (1.x)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 10 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch Unreleased (1.x)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 10 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.4.1)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 10 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.4.1)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 10 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.9.0)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 10 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.9.0)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 10 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.3.0)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 10 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.3.0)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 10 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Create Release Artifacts

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 10 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Create Release Artifacts

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 10 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.8.0)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 10 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch (2.8.0)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 10 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch Unreleased (main)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 10 in samples/Samples/Program.cs

View workflow job for this annotation

GitHub Actions / Integration OpenSearch Unreleased (main)

The type or namespace name 'OpenSearch' could not be found (are you missing a using directive or an assembly reference?)


public class Program
{
public static async Task Main(string[] args)
{
var node = new Uri("https://localhost:9200");
var config = new ConnectionSettings(node)
.ServerCertificateValidationCallback(CertificateValidations.AllowAll)
.BasicAuthentication("admin", "admin")
.DisableDirectStreaming();

var client = new OpenSearchClient(config);


// Sample Code: Making Raw JSON Requests

// GET
var versionResponse = await client.LowLevel.DoRequestAsync<DynamicResponse>(HttpMethod.GET, "/", CancellationToken.None);
Console.WriteLine(versionResponse.Body["version"]["distribution"].ToString() + " " + versionResponse.Body["version"]["number"].ToString());

// PUT
var indexBody = new
{
settings = new
{
index = new
{
number_of_shards = 4
}
}
};

var putResponse = await client.LowLevel.DoRequestAsync<DynamicResponse>(HttpMethod.PUT, "/movies", CancellationToken.None, PostData.Serializable(indexBody));

// POST
string q = "miller";

var query = new
{
size = 5,
query = new
{
multi_match = new
{
query = q,
fields = new[] { "title^2", "director" }
}
}
};

var postResponse = await client.LowLevel.DoRequestAsync<DynamicResponse>(HttpMethod.POST, "/movies/_search", CancellationToken.None, PostData.Serializable(query));

// DELETE
var deleteResponse = await client.LowLevel.DoRequestAsync<DynamicResponse>(HttpMethod.DELETE, "/movies", CancellationToken.None);
}
}
15 changes: 15 additions & 0 deletions samples/Samples/Samples.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>False</IsPackable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="OpenSearch.Client" Version="1.*" />
</ItemGroup>

</Project>

0 comments on commit 6e38e9f

Please sign in to comment.