Versions (relevant - OpenSearch/Dashboard/Server OS/Browser):
OpenSearchClient 1.8.0
Open Search cluster 7.10.2
Describe the issue:
Our models don’t have numeric Id fields, but strings. I want to use the GetAsync and MultiGetAsync API’s to retrieve documents based on these IDs, but the client assumes the Id’s are numeric, and throws an error when strings are passed.
The REST API does not have this limitation, I can execute a GET against /institutionmodel/_doc/0nJ1CjuKe0efMRBV just fine and get data. But when I do this in C# using the client I get an exception that a numeric token is expected. Happens both in GetAsync and MultiGetAsync
Configuration:
Relevant Logs or Screenshots:
Error: expected:‘Number Token’, actual:‘“0nJ1CjuKe0efMRBV”’, at offset:612
This is the relevant code:
private static async Task TestGetAsync()
{
var settings = new ConnectionSettings(new Uri("my_cluster_address"));
var client = new OpenSearchClient(settings);
var indexName = "institutionmodel";
var id = "0nJ1CjuKe0efMRBV";
try
{
var singleResponse = await client.GetAsync<InstitutionModel>(id, m => m.Index(indexName));
if (singleResponse.IsValid)
{
var result = singleResponse.Source;
Console.WriteLine($"Loaded model {id} from Elastic: {result?.Name}");
}
else
{
Console.WriteLine($"Unable to load model {id} from Elastic " + singleResponse?.ServerError?.Error?.Reason);
}
}
catch (Exception ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
}