Skip to content

jakarta.json.stream.JsonParsingException: Property name 'key' is not in the 'type#name' format. Make sure the request has 'typed_keys' set. #358

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
houbbbbb opened this issue Jul 23, 2022 · 6 comments
Labels
Category: Bug Something isn't working

Comments

@houbbbbb
Copy link

Java API client version

7.16.2

Java version

11

Elasticsearch Version

7.16.2

Problem description

akarta.json.stream.JsonParsingException: Property name 'key' is not in the 'type#name' format. Make sure the request has 'typed_keys' set.

at co.elastic.clients.json.ExternallyTaggedUnion$TypedKeysDeserializer.deserializeEntry(ExternallyTaggedUnion.java:102)
at co.elastic.clients.elasticsearch._types.aggregations.MultiBucketBase.lambda$setupMultiBucketBaseDeserializer$0(MultiBucketBase.java:161)
at co.elastic.clients.elasticsearch._types.aggregations.MultiBucketBase$$Lambda$1166/56960427.accept(Unknown Source)
at co.elastic.clients.json.ObjectDeserializer.parseUnknownField(ObjectDeserializer.java:205)
at co.elastic.clients.json.ObjectDeserializer.deserialize(ObjectDeserializer.java:174)
at co.elastic.clients.json.ObjectDeserializer.deserialize(ObjectDeserializer.java:137)
at co.elastic.clients.json.ObjectBuilderDeserializer.deserialize(ObjectBuilderDeserializer.java:85)
at co.elastic.clients.json.DelegatingDeserializer$SameType.deserialize(DelegatingDeserializer.java:48)
at co.elastic.clients.json.JsonpDeserializerBase$ArrayDeserializer.deserialize(JsonpDeserializerBase.java:320)
at co.elastic.clients.json.JsonpDeserializerBase$ArrayDeserializer.deserialize(JsonpDeserializerBase.java:285)
at co.elastic.clients.json.UnionDeserializer$SingleMemberHandler.deserialize(UnionDeserializer.java:75)
at co.elastic.clients.json.UnionDeserializer.deserialize(UnionDeserializer.java:292)
at co.elastic.clients.json.UnionDeserializer.deserialize(UnionDeserializer.java:259)
at co.elastic.clients.json.ObjectDeserializer$FieldObjectDeserializer.deserialize(ObjectDeserializer.java:72)
at co.elastic.clients.json.ObjectDeserializer.deserialize(ObjectDeserializer.java:176)
at co.elastic.clients.json.ObjectDeserializer.deserialize(ObjectDeserializer.java:137)
at co.elastic.clients.json.ObjectBuilderDeserializer.deserialize(ObjectBuilderDeserializer.java:85)
at co.elastic.clients.json.DelegatingDeserializer$SameType.deserialize(DelegatingDeserializer.java:48)
at co.elastic.clients.json.ExternallyTaggedUnion$Deserializer.deserialize(ExternallyTaggedUnion.java:68)
at co.elastic.clients.json.ExternallyTaggedUnion$TypedKeysDeserializer.deserializeEntry(ExternallyTaggedUnion.java:109)
at co.elastic.clients.json.ExternallyTaggedUnion$TypedKeysDeserializer.deserialize(ExternallyTaggedUnion.java:92)
at co.elastic.clients.json.ExternallyTaggedUnion$TypedKeysDeserializer.deserialize(ExternallyTaggedUnion.java:80)
at co.elastic.clients.json.JsonpDeserializer.deserialize(JsonpDeserializer.java:75)
at co.elastic.clients.json.ObjectDeserializer$FieldObjectDeserializer.deserialize(ObjectDeserializer.java:72)
at co.elastic.clients.json.ObjectDeserializer.deserialize(ObjectDeserializer.java:176)
at co.elastic.clients.json.ObjectDeserializer.deserialize(ObjectDeserializer.java:137)
at co.elastic.clients.json.JsonpDeserializer.deserialize(JsonpDeserializer.java:75)
at co.elastic.clients.json.ObjectBuilderDeserializer.deserialize(ObjectBuilderDeserializer.java:79)
at co.elastic.clients.json.DelegatingDeserializer$SameType.deserialize(DelegatingDeserializer.java:43)
at co.elastic.clients.transport.endpoints.EndpointWithResponseMapperAttr$1.deserialize(EndpointWithResponseMapperAttr.java:56)
at co.elastic.clients.transport.rest_client.RestClientTransport.decodeResponse(RestClientTransport.java:328)
at co.elastic.clients.transport.rest_client.RestClientTransport.getHighLevelResponse(RestClientTransport.java:294)
at co.elastic.clients.transport.rest_client.RestClientTransport.performRequest(RestClientTransport.java:147)
at co.elastic.clients.elasticsearch.ElasticsearchClient.search(ElasticsearchClient.java:1487)
at com.hou.es.search.standard.bucket.adjacencymatrix.AdjacencyMatrixServiceImpl.adjacencyMatrix(AdjacencyMatrixServiceImpl.java:45)
at com.hou.es.search.standard.bucket.adjacencymatrix.AdjacencyMatrixServiceImplAdjacencyMatrixTest.adjacencyMatrix(AdjacencyMatrixServiceImplAdjacencyMatrixTest.java:19)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:725)
at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149)
at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:140)
at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:84)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor$$Lambda$122/521081105.apply(Unknown Source)
at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall$$Lambda$123/158199555.apply(Unknown Source)
at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
at org.junit.jupiter.engine.execution.ExecutableInvoker$$Lambda$369/565881091.apply(Unknown Source)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$7(TestMethodTestDescriptor.java:214)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor$$Lambda$890/743936514.execute(Unknown Source)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:210)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:135)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:66)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151)
at org.junit.platform.engine.support.hierarchical.NodeTestTask$$Lambda$224/1536471117.execute(Unknown Source)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.NodeTestTask$$Lambda$223/945722724.invoke(Unknown Source)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.NodeTestTask$$Lambda$222/1781493632.execute(Unknown Source)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService$$Lambda$228/422330142.accept(Unknown Source)
at java.util.ArrayList.forEach(Unknown Source)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
at org.junit.platform.engine.support.hierarchical.NodeTestTask$$Lambda$224/1536471117.execute(Unknown Source)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.NodeTestTask$$Lambda$223/945722724.invoke(Unknown Source)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.NodeTestTask$$Lambda$222/1781493632.execute(Unknown Source)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService$$Lambda$228/422330142.accept(Unknown Source)
at java.util.ArrayList.forEach(Unknown Source)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
at org.junit.platform.engine.support.hierarchical.NodeTestTask$$Lambda$224/1536471117.execute(Unknown Source)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.NodeTestTask$$Lambda$223/945722724.invoke(Unknown Source)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.NodeTestTask$$Lambda$222/1781493632.execute(Unknown Source)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator$$Lambda$166/1664439369.accept(Unknown Source)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53)
at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:71)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:221)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)

.aggregations("interactions", agg -> agg
.adjacencyMatrix(adj -> adj
.filters("gpA", q -> q
.term(tm -> tm
.field("title").
value(v -> v
.stringValue("hello")))))));

When I use adjacencyMatrix. It throws this Exception

@gaurav-goenka
Copy link

I'm seeing the same exception too. Did you find a solution to this?

@am-thete
Copy link

I am getting same exception in Java API client ver. 8.11.3, java 8 also. I am using Elasticsearch Search application and searching using SearchApplicationSearchRequest. The search function of ElasticearchApplicationClient gives this exception.

It fails to parse the aggretion in response. Same API works properly in ES Dev tools.

POST _application/search_application/my-app/_search
{
"params": {
"query_string": "my-query-string",
"from": "0",
"size": "5",
"facets": [
{
"name": "Language",
"field": "locale"
}
]
}
}

@l-trotta l-trotta added the Category: Bug Something isn't working label Feb 21, 2024
@l-trotta
Copy link
Contributor

Hello and thanks for the report. I tried reproducing this issue using adjacencyMatrix, but didn't manage to get an exception, so it might be something we already fixed, If this is still an issue @houbbbbb please let us know.

@am-thete could you please provide a snippet of the java code that is failing? Thank you!

@am-thete
Copy link

Hello,

There was existing issue #306 and #316. As per comments in issues, this is fixed #316 and code is already merged. I tried to solution mentioned in https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/serialize-without-typed-keys.html as well but no luck.

The difference I have is I am using ElasticsearchSearchApplicationSearch, SearchApplicationSearchRequest and SearchApplicationSearchResponse to search document against my SearchApplication. Here is code snippet

// ElasticsearchSearchApplication
// Create the low-level client
RestClient restClient = RestClient.builder(HttpHost.create(serverUrl))
.setDefaultHeaders(new Header[] { new BasicHeader("Authorization", "ApiKey " + apiKey) }).build();

// Create the transport with a Jackson mapper
JsonpMapper jacksonMapper = new JacksonJsonpMapper();
jacksonMapper = jacksonMapper.withAttribute(JsonpMapperFeatures.SERIALIZE_TYPED_KEYS, true);
ElasticsearchTransport transport = new RestClientTransport(restClient, jacksonMapper);
// end::create-client

ElasticsearchSearchApplicationClient esSearchClient = new ElasticsearchSearchApplicationClient(transport);_

// SearchApplicationsearchRequest.Builder
SearchApplicationSearchRequest.Builder builder = new SearchApplicationSearchRequest.Builder();
builder.name(searchApplicationName);

// Create SearchApplicationSearchRequesting by adding params - Filters and facets
requestMap.put("filters", JsonData.fromJson(jsonArrayFilters));
requestMap.put("facets", JsonData.fromJson(jsonArrayFacets));
builder.params(requestMap);
SearchApplicationSearchRequest searchgApplicationSearchRequest = builder.build();

// Perform search against SearchApplication
SearchApplicationSearchResponse searchResponse;
searchResponse = esSearchClient.search(searchgApplicationSearchRequest, Object.class); - Exception is received at this line

The issue is with the Aggregation. It fails in deserializing Aggregation

@am-thete
Copy link

at co.elastic.clients.json.ExternallyTaggedUnion$TypedKeysDeserializer.deserializeEntry(ExternallyTaggedUnion.java:123)
at co.elastic.clients.json.ExternallyTaggedUnion$TypedKeysDeserializer.deserialize(ExternallyTaggedUnion.java:113)
at co.elastic.clients.json.ExternallyTaggedUnion$TypedKeysDeserializer.deserialize(ExternallyTaggedUnion.java:101)
at co.elastic.clients.json.JsonpDeserializer.deserialize(JsonpDeserializer.java:77)
at co.elastic.clients.json.ObjectDeserializer$FieldObjectDeserializer.deserialize(ObjectDeserializer.java:78)
at co.elastic.clients.json.ObjectDeserializer.deserialize(ObjectDeserializer.java:192)
at co.elastic.clients.json.ObjectDeserializer.deserialize(ObjectDeserializer.java:148)
at co.elastic.clients.json.JsonpDeserializer.deserialize(JsonpDeserializer.java:77)
at co.elastic.clients.json.ObjectBuilderDeserializer.deserialize(ObjectBuilderDeserializer.java:79)
at co.elastic.clients.json.DelegatingDeserializer$SameType.deserialize(DelegatingDeserializer.java:43)
at co.elastic.clients.json.DelegatingDeserializer$SameType.deserialize(DelegatingDeserializer.java:43)
at co.elastic.clients.transport.endpoints.EndpointWithResponseMapperAttr$1.deserialize(EndpointWithResponseMapperAttr.java:56)
at co.elastic.clients.transport.ElasticsearchTransportBase.decodeTransportResponse(ElasticsearchTransportBase.java:399)

@l-trotta
Copy link
Contributor

l-trotta commented Jun 4, 2024

@am-thete SearchApplicationSearch had a bug in the server code where the typed_keys parameter was not supported, hence making it not possible for the java client to deserialize aggregation responses. This has now been fixed and it should be part of one of the next releases, I'll update this issue when the fix will be officially out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants