You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Operating system version:
docker with linux container
Description of the problem including expected versus actual behavior:
I had this error in two cases:
when I try to change analyzer ( exactly update synonyms and stopwords ) (static setting on closed index)
when I try to block/unblock write on index (dynamic setting on open index)
In both cases I use similar code like for index creation (its working there, index is created with given settings).
But when I use PutSettingsAsync I get error "request body is required". From debugging I know that my settings are correctly serializable (using JsonSerializer), but they're lost somewhere inside Elastic.Transport.PostData.WriteAsync function. Stream which should contain my settings was empty, which lead to serialization into empty json {} and in result give error "request body is required" )
Steps to reproduce:
Please use code like this (simplified version, _elasticClient initialized by dependency injection):
var sourceIndexName ="testindex"; // it exists and is open
IndexSettings sourceIndexSettings = new IndexSettings();
sourceIndexSettings.Blocks = new IndexSettingBlocks() { Write = true };
try
{
var x = JsonSerializer.Serialize<IndexSettings>(sourceIndexSettings); // test => x contain correct json
}
catch (Exception ex)
{
}
var updateStatusSrc = await _elasticClient.Indices.PutSettingsAsync(sourceIndexSettings, Indices.Index(sourceIndexName));
or this code
var indexName ="testindex"; // it exists and is open
await _elasticClient.Indices.CloseAsync(indexName);
IndexSettings settings = new IndexSettings();
settings.MaxNgramDiff = 20;
IndexSettingsAnalysis analysis = new IndexSettingsAnalysis();
TokenFilters tokenFilters = new TokenFilters();
tokenFilters.Add("custom_asciifolding", new AsciiFoldingTokenFilter() { PreserveOriginal = true });
tokenFilters.Add("custom_polish_stop", new StopTokenFilter() { Stopwords = ["a","i","z"], RemoveTrailing = true });
tokenFilters.Add("substrings", new EdgeNGramTokenFilter() { MinGram = 2, MaxGram = 20 });
tokenFilters.Add("custom_synonym", new SynonymGraphTokenFilter() { Synonyms =
[
"dom, chata, budynek",
"zwierzę, pies, kot"
]
});
analysis.TokenFilters = tokenFilters;
Analyzers analyzers = new Analyzers();
analyzers.Add("custom_analyzer", new CustomAnalyzer() {
Tokenizer = "standard",
CharFilter = ["html_strip"],
Filter = [
"lowercase",
"custom_polish_stop",
"substrings",
"custom_asciifolding"
]
});
analysis.Analyzers = analyzers;
settings.Analysis = analysis;
try
{
var x = JsonSerializer.Serialize<IndexSettings>(settings); // test , x contains correct json with settings
}
catch (Exception ex)
{
}
var updateStatus = await _elasticClient.Indices.PutSettingsAsync(settings, Indices.Index(indexName));
Expected behavior
Index settings should be updated according to new settings, other settings should not be changed (preserve existing was not required in 7.x version)
Provide ConnectionSettings (if relevant):
Most notable:
EnableHttpCompression = true // also tried with false, error stays the same
DisableDirectStreaming = false // also tried with true, error stays the same
Provide DebugInformation (if relevant):
stacktrace:
Elastic.Transport.TransportException: Request failed to execute. Call: Status code 400 from: PUT /testindex/_settings?pretty=true. ServerError: Type: parse_exception Reason: "request body is required"
at Elastic.Transport.DistributedTransport`1.HandleTransportException(RequestData data, Exception clientException, TransportResponse response)
at Elastic.Transport.DistributedTransport`1.FinalizeResponse[TResponse](RequestData requestData, RequestPipeline pipeline, List`1 seenExceptions, TResponse response)
at Elastic.Transport.DistributedTransport`1.RequestCoreAsync[TResponse](Boolean isAsync, HttpMethod method, String path, PostData data, RequestParameters requestParameters, OpenTelemetryData openTelemetryData, CancellationToken cancellationToken)
Regards,
Arnold
The text was updated successfully, but these errors were encountered:
Elastic.Clients.Elasticsearch version:
8.13.12
Elasticsearch version:
8.9
.NET runtime version:
net 8
Operating system version:
docker with linux container
Description of the problem including expected versus actual behavior:
I had this error in two cases:
In both cases I use similar code like for index creation (its working there, index is created with given settings).
But when I use PutSettingsAsync I get error "request body is required". From debugging I know that my settings are correctly serializable (using JsonSerializer), but they're lost somewhere inside Elastic.Transport.PostData.WriteAsync function. Stream which should contain my settings was empty, which lead to serialization into empty json
{}
and in result give error "request body is required" )Steps to reproduce:
Please use code like this (simplified version, _elasticClient initialized by dependency injection):
or this code
Expected behavior
Index settings should be updated according to new settings, other settings should not be changed (preserve existing was not required in 7.x version)
Provide
ConnectionSettings
(if relevant):Most notable:
EnableHttpCompression = true // also tried with false, error stays the same
DisableDirectStreaming = false // also tried with true, error stays the same
Provide
DebugInformation
(if relevant):stacktrace:
Regards,
Arnold
The text was updated successfully, but these errors were encountered: