High level client parse aggregation in response of GetAsyncSearchRequest failed

Hi
i got problem that high level client parse aggregation in response of GetAsyncSearchRequest failed.Get async request in kibana as:

GET /_async_search/FjJxanhwbHpoUS1lUXFDU2M1ajEyVHcdVnp4Z09RT3VTdjZYZWxDUUx3dDRMUToxMzMwNjA=

It works ok,and response is:

{
  "id" : "FjJxanhwbHpoUS1lUXFDU2M1ajEyVHcdVnp4Z09RT3VTdjZYZWxDUUx3dDRMUToxMzMwNjA=",
  "is_partial" : false,
  "is_running" : false,
  "start_time_in_millis" : 1614260436413,
  "expiration_time_in_millis" : 1614350448390,
  "response" : {
    "took" : 121,
    "timed_out" : false,
    "_shards" : {
      "total" : 5,
      "successful" : 5,
      "skipped" : 0,
      "failed" : 0
    },
    "hits" : {
      "total" : {
        "value" : 10000,
        "relation" : "gte"
      },
      "max_score" : null,
      "hits" : [ ]
    },
    "aggregations" : {
      "termDATE_HISTOGRAMcd" : {
        "buckets" : [
          {
            "key_as_string" : "2021-02-24",
            "key" : 1614124800000,
            "doc_count" : 830011,
            "termTERMct" : {
              "doc_count_error_upper_bound" : 0,
              "sum_other_doc_count" : 0,
              "buckets" : [
                {
                  "key" : 1,
                  "doc_count" : 586508,
                  "countCOUNT_DISTINCTdid" : {
                    "value" : 477670
                  }
                },
                {
                  "key" : 0,
                  "doc_count" : 243503,
                  "countCOUNT_DISTINCTdid" : {
                    "value" : 214642
                  }
                }
              ]
            }
          }
        ]
      }
    }
  }
}

when I use high level client asyncSearchAsynchronous Execution,as follow:

        GetAsyncSearchRequest request = new GetAsyncSearchRequest(searchId);
        try {
            AsyncSearchResponse response = elasticsearchClient.asyncSearch().get(request, RequestOptions.DEFAULT);
        } catch (IOException e) {
            e.printStackTrace();
        }

it throw parse Exception:

    java.io.IOException: Unable to parse response body for Response{requestLine=GET /_async_search/FjBsYVpBelpWUy1PTlQ4MTlicTVmN3cdVnp4Z09RT3VTdjZYZWxDUUx3dDRMUToxMjM0NTI=?wait_for_completion_timeout=10000ms&keep_alive=1500m HTTP/1.1, host=http://172.23.32.134:9200, response=HTTP/1.1 200 OK}
	at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1651)
	at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:1617)
	at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:1584)
	at org.elasticsearch.client.AsyncSearchClient.get(AsyncSearchClient.java:75)
	at com.ztc.advert.logAnalyse.util.es.ElasticSearchUtil.getAsyncSearch(ElasticSearchUtil.java:111)
	at com.ztc.advert.logAnalyse.service.TestServiceTest.testAsync(TestServiceTest.java:63)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.springframework.test.context.junit4.statements.RunBeforeTestExecutionCallbacks.evaluate(RunBeforeTestExecutionCallbacks.java:74)
	at org.springframework.test.context.junit4.statements.RunAfterTestExecutionCallbacks.evaluate(RunAfterTestExecutionCallbacks.java:84)
	at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
	at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
	at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:251)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
	at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)
	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)
Caused by: org.elasticsearch.common.xcontent.XContentParseException: [1:723] [submit_async_search_response] failed to parse field [response]
	at org.elasticsearch.common.xcontent.ObjectParser.parseValue(ObjectParser.java:531)
	at org.elasticsearch.common.xcontent.ObjectParser.parseSub(ObjectParser.java:541)
	at org.elasticsearch.common.xcontent.ObjectParser.parse(ObjectParser.java:324)
	at org.elasticsearch.common.xcontent.ConstructingObjectParser.parse(ConstructingObjectParser.java:171)
	at org.elasticsearch.common.xcontent.ConstructingObjectParser.apply(ConstructingObjectParser.java:163)
	at org.elasticsearch.client.asyncsearch.AsyncSearchResponse.fromXContent(AsyncSearchResponse.java:193)
	at org.elasticsearch.client.RestHighLevelClient.parseEntity(RestHighLevelClient.java:1911)
	at org.elasticsearch.client.RestHighLevelClient.lambda$performRequestAndParseEntity$9(RestHighLevelClient.java:1585)
	at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1649)
	... 35 more
Caused by: ParsingException[Could not parse aggregation keyed as [termDATE_HISTOGRAMcd]]
	at org.elasticsearch.search.aggregations.Aggregations.fromXContent(Aggregations.java:147)
	at org.elasticsearch.action.search.SearchResponse.innerFromXContent(SearchResponse.java:335)
	at org.elasticsearch.client.asyncsearch.AsyncSearchResponse.parseSearchResponse(AsyncSearchResponse.java:189)
	at org.elasticsearch.client.asyncsearch.AsyncSearchResponse.lambda$static$1(AsyncSearchResponse.java:180)
	at org.elasticsearch.common.xcontent.AbstractObjectParser.lambda$declareObject$1(AbstractObjectParser.java:170)
	at org.elasticsearch.common.xcontent.ObjectParser.lambda$declareField$9(ObjectParser.java:386)
	at org.elasticsearch.common.xcontent.ObjectParser.parseValue(ObjectParser.java:529)
	... 43 more

what caused this problem? is it because lack of aggregation type in response content?
How can I solve it,or debug it? Must I use low level client?

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.