Comments (5)
@giannik Manual (De-)serialization of the data structures is an unsupported use-case.
In this particular case, the json converter relies on a settings structure that is managed by the client.
In other cases, your JsonSerializer simply does not know about the internal default converters and/or certain types only implement either serialization OR deserialization.
You could try to use "client.RequestResponseSerializer.Serialize()", but there is no guarantee this works all the time.
Usually we suggest using your own custom CLR types and copy over / assign the values from the Elasticsearch types.
from elasticsearch-net.
Hi @giannik, could you please post the actual exception as thrown by the Elasticsearch client or Elastic.Transport? The callstack from your image does not show the relevant methods. You'll probably have to inspect the inner exceptions.
from elasticsearch-net.
@flobernd here it is :
hmm , now that im looking at it it might be my code causng problem here : OrchardCore.Abstractions\Json\Nodes\JNode.cs:line 39
GET https://0c855f771a5f47dd8541e202bb8c6640.westeurope.azure.elastic-cloud.com/default_dasfsdfs/_mapping
Status: 200
{"default_dasfsdfs":{"mappings":{"_meta":{"last_task_id":0},"_source":{"enabled":true,"excludes":["ContentItem_DisplayText_Analyzed"]},"properties":{"ContentItemId":{"type":"keyword"},"ContentItemVersionId":{"type":"keyword"},"ContentItem_ContainedPart":{"properties":{"Ids":{"type":"keyword"},"Order":{"type":"keyword"}}},"ContentItem_ContentType":{"type":"keyword"},"ContentItem_DisplayText":{"properties":{"Analyzed":{"type":"text"},"Keyword":{"type":"keyword"},"Normalized":{"type":"keyword"}}},"ContentItem_FullText":{"type":"keyword"},"ContentItem_Owner":{"type":"keyword"},"ContentItem_Vector":{"type":"nested","properties":{"Memory":{"type":"dense_vector","dims":1536,"index":true,"similarity":"cosine","index_options":{"type":"int8_hnsw","m":16,"ef_construction":100}},"Text":{"type":"text","index":false}}}}}}}
fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
An unhandled exception has occurred while executing the request.
System.Text.Json.JsonReaderException: 'V' is an invalid start of a value. LineNumber: 0 | BytePositionInLine: 0.
at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan`1 bytes)
at System.Text.Json.Utf8JsonReader.ConsumeValue(Byte marker)
at System.Text.Json.Utf8JsonReader.ReadFirstToken(Byte first)
at System.Text.Json.Utf8JsonReader.ReadSingleSegment()
at System.Text.Json.JsonDocument.Parse(ReadOnlySpan`1 utf8JsonSpan, JsonReaderOptions readerOptions, MetadataDb& database, StackRowStack& stack)
at System.Text.Json.JsonDocument.ParseUnrented(ReadOnlyMemory`1 utf8Json, JsonReaderOptions readerOptions, JsonTokenType tokenType)
at System.Text.Json.JsonDocument.ParseValue(ReadOnlyMemory`1 json, JsonDocumentOptions options)
at System.Text.Json.Nodes.JsonNode.Parse(String json, Nullable`1 nodeOptions, JsonDocumentOptions documentOptions)
at System.Text.Json.Nodes.JNode.Parse(String json, Nullable`1 nodeOptions, JsonDocumentOptions documentOptions) in C:\IntelliDev20\src\OrchardCore\OrchardCore.Abstractions\Json\Nodes\JNode.cs:line 50
at System.Text.Json.Nodes.JNode.Parse(String json) in C:\IntelliDev20\src\OrchardCore\OrchardCore.Abstractions\Json\Nodes\JNode.cs:line 39
at OrchardCore.Search.Elasticsearch.AdminController.Mappings(String indexName) in C:\IntelliDev20\src\OrchardCore.Modules\OrchardCore.Search.Elasticsearch\Controllers\AdminController.cs:line 442
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Logged|12_1(ControllerActionInvoker invoker)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at SixLabors.ImageSharp.Web.Middleware.ImageSharpMiddleware.Invoke(HttpContext httpContext, Boolean retry)
at OrchardCore.Liquid.ScriptsMiddleware.Invoke(HttpContext httpContext) in C:\IntelliDev20\src\OrchardCore.Modules\OrchardCore.Liquid\ScriptsMiddleware.cs:line 70
at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at OrchardCore.Diagnostics.DiagnosticsStartupFilter.<>c__DisplayClass3_0.<<Configure>b__1>d.MoveNext() in C:\IntelliDev20\src\OrchardCore.Modules\OrchardCore.Diagnostics\DiagnosticsStartupFilter.cs:line 34
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
at OrchardCore.ContentPreview.PreviewStartupFilter.<>c.<<Configure>b__0_1>d.MoveNext() in C:\IntelliDev20\src\OrchardCore.Modules\OrchardCore.ContentPreview\PreviewStartupFilter.cs:line 16
--- End of stack trace from previous location ---
at OrchardCore.Modules.ModularTenantRouterMiddleware.Invoke(HttpContext httpContext) in C:\IntelliDev20\src\OrchardCore\OrchardCore\Modules\ModularTenantRouterMiddleware.cs:line 47
at OrchardCore.Modules.ModularTenantContainerMiddleware.<>c__DisplayClass4_0.<<Invoke>b__0>d.MoveNext() in C:\IntelliDev20\src\OrchardCore\OrchardCore\Modules\ModularTenantContainerMiddleware.cs:line 61
--- End of stack trace from previous location ---
at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell) in C:\IntelliDev20\src\OrchardCore\OrchardCore.Abstractions\Shell\Scope\ShellScope.cs:line 291
at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell) in C:\IntelliDev20\src\OrchardCore\OrchardCore.Abstractions\Shell\Scope\ShellScope.cs:line 296
at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell) in C:\IntelliDev20\src\OrchardCore\OrchardCore.Abstractions\Shell\Scope\ShellScope.cs:line 301
at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell) in C:\IntelliDev20\src\OrchardCore\OrchardCore.Abstractions\Shell\Scope\ShellScope.cs:line 306
at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell) in C:\IntelliDev20\src\OrchardCore\OrchardCore.Abstractions\Shell\Scope\ShellScope.cs:line 307
at OrchardCore.Modules.ModularTenantContainerMiddleware.Invoke(HttpContext httpContext) in C:\IntelliDev20\src\OrchardCore\OrchardCore\Modules\ModularTenantContainerMiddleware.cs:line 59
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)
from elasticsearch-net.
ok , the original error was my fault so please ignore it.
but when i get the repsonse and try to serialize to json as so :
JsonSerializer.Serialize(response.Indices.FirstOrDefault().Value.Mappings, new JsonSerializerOptions());
i get the following error :
Unable to retrieve client settings for JsonSerializerOptions.
Path:$.Properties
at Elastic.Clients.Elasticsearch.ThrowHelper.ThrowJsonExceptionForMissingSettings() in /_/src/Elastic.Clients.Elasticsearch.Shared/Core/Exceptions/ThrowHelper.cs:line 40
at Elastic.Clients.Elasticsearch.Mapping.PropertiesConverter.Write(Utf8JsonWriter writer, Properties value, JsonSerializerOptions options) in /_/src/Elastic.Clients.Elasticsearch.Shared/Types/Mapping/Properties.cs:line 62
at System.Text.Json.Serialization.JsonConverter`1.TryWrite(Utf8JsonWriter writer, T& value, JsonSerializerOptions options, WriteStack& state)
at System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1.GetMemberAndWriteJson(Object obj, WriteStack& state, Utf8JsonWriter writer)
at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryWrite(Utf8JsonWriter writer, T value, JsonSerializerOptions options, WriteStack& state)
at System.Text.Json.Serialization.JsonConverter`1.TryWrite(Utf8JsonWriter writer, T& value, JsonSerializerOptions options, WriteStack& state)
at System.Text.Json.Serialization.JsonConverter`1.WriteCore(Utf8JsonWriter writer, T& value, JsonSerializerOptions options, WriteStack& state)
at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.Serialize(Utf8JsonWriter writer, T& rootValue, Object rootValueBoxed)
at System.Text.Json.JsonSerializer.WriteString[TValue](TValue& value, JsonTypeInfo`1 jsonTypeInfo)
at System.Text.Json.JsonSerializer.Serialize[TValue](TValue value, JsonSerializerOptions options)
from elasticsearch-net.
@flobernd thanks
client.RequestResponseSerializer.Serialize() worked !
from elasticsearch-net.
Related Issues (20)
- Cannot retrieve mapping of index with `icu_collation_keyword` field HOT 6
- cannot instantiate new DynamicTemplate when creating index. HOT 4
- Default index is not used in query with 8.13.15 client HOT 1
- Missing properties in aggregation API HOT 3
- Improve documentation for error handling
- Elastic.Transport.UnexpectedTransportException when calling elasticClient.MachineLearning.InferTrainedModelAsync HOT 1
- Support for using input_output option in inference processor
- CI: Automate reference documentation
- Intervals query is missing the option to set Field HOT 3
- Fluent API for composite aggregation sources
- IndexSettingsConverter tries to deserialize routing_path as collection of string even if there is a string in raw JSON response HOT 1
- ESQL Arrow support
- Implement Connectors API
- Add back TermsRangeQuery in the Elasticsearch .Net Client HOT 1
- Cannot run knn query using elasticClient.RequestResponseSerializer HOT 4
- Improve usability of `FiltersAggregation`
- Adding document to Elastic with Client.IndexAsync doesn't await result; also ambigious function parameters HOT 7
- ElasticsearchClient.Indicies.GetAsync throws UnexpectedTransportException
- IndexSettings NumberOfShards and NumberOfReplicas are objects, not int/long as expected HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elasticsearch-net.