I think that if you do

SearchResponse response = esClient.prepareSearch("person")
                .setTypes("person")
                .addAggregation(
                        AggregationBuilders.terms("by_country").field("country")
                )
                .execute().actionGet();

logger.trace("elasticsearch response: {}", response.toString());

You will have directly the JSON response.

-- 
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr


Le 17 septembre 2014 à 17:01:41, [email protected] ([email protected]) a 
écrit:

I am using Java client.
I wanted to convert elasticsearch objects to JSON responses. The JSON result 
above was the expected result.

I successfully convert it with Jackson by switching 
SerializationFeature.FAIL_ON_EMPTY_BEANS to false which seems mandatory to 
serialize aggregation elasticsearch objects.

Sorry, my question wasn't clear.

On Wednesday, September 17, 2014 3:53:58 PM UTC+2, David Pilato wrote:
Why don't you use Java client?

If you are using it why do you need to convert JSON responses to elasticsearch 
objects?
I don't understand exactly what you are trying to do here.


-- 
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr


Le 17 septembre 2014 à 11:57:24, [email protected] ([email protected]) a 
écrit:

I have a problem with Java API and aggregations result

Serializer (jackson) produce this error:
No serializer found for class org.elasticsearch.common.text.StringText and no 
properties discovered to create BeanSerializer

for this query :

{
    "size": 0,
    "aggregations": {
        "agg": {
            "global": {},
            "aggregations": {
                "dim-1": {
                    "terms": {
                        "field": "field-1"
                    },
                    "aggregations": {
                        "dim-2": {
                            "terms": {
                                "field": "field-2"
                            },
                            "aggregations": {
                                "myStats": {
                                    "stats": {
                                        "field": "statsField"
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}


with this response :

{
   "took":15932,
   "timed_out":false,
   "_shards":{
      "total":2,
      "successful":2,
      "failed":0
   },
   "hits":{
      "total":38376901,
      "max_score":0,
      "hits":[
 
      ]
   },
   "aggregations":{
      "agg":{
         "doc_count":38376901,
         "dim-1":{
            "buckets":[
               {
                  "key":27380,
                  "doc_count":311352,
                  "dim-2":{
                     "buckets":[
                        {
                           "key":1,
                           "doc_count":275581,
                           "statsField":{
                              "count":275581,
                              "min":245,
                              "max":1295001,
                              "avg":111170.57729999075,
                              "sum":30636498862.908752
                           }
                        },
                        {
                           "key":2,
                           "doc_count":35771,
                           "statsField":{
                              "count":35771,
                              "min":300,
                              "max":2070000,
<div class="de2" style="-webkit-user-select: text; padding-right: 5px; 
padding-left: 5px; vertical-align: top; color: rgb(0, 0, 0); border-left-width: 
1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); 
margin-left: -7px; position: relative; line-height: 21px; backgrou
...
--
You received this message because you are subscribed to the Google Groups 
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/445d7b7f-fe03-4df3-87f4-fbe54b058c62%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/etPan.5419a331.6b94764.3c6%40MacBook-Air-de-David.local.
For more options, visit https://groups.google.com/d/optout.

Reply via email to