Java API and aggregations result problem

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 :

  1. {
  2. "size": 0,
    
  3. "aggregations": {
    
  4.     "agg": {
    
  5.         "global": {},
    
  6.         "aggregations": {
    
  7.             "dim-1": {
    
  8.                 "terms": {
    
  9.                     "field": "field-1"
    
  10.                 },
    
  11.                 "aggregations": {
    
  12.                     "dim-2": {
    
  13.                         "terms": {
    
  14.                             "field": "field-2"
    
  15.                         },
    
  16.                         "aggregations": {
    
  17.                             "myStats": {
    
  18.                                 "stats": {
    
  19.                                     "field": "statsField"
    
  20.                                 }
    
  21.                             }
    
  22.                         }
    
  23.                     }
    
  24.                 }
    
  25.             }
    
  26.         }
    
  27.     }
    
  28. }
    
  29. }

with this response :

  1. {
  2. "took":15932,
  3. "timed_out":false,
  4. "_shards":{
  5.   "total":2,
    
  6.   "successful":2,
    
  7.   "failed":0
    
  8. },
  9. "hits":{
  10.   "total":38376901,
    
  11.   "max_score":0,
    
  12.   "hits":[
    
  13.   ]
    
  14. },
  15. "aggregations":{
  16.   "agg":{
    
  17.      "doc_count":38376901,
    
  18.      "dim-1":{
    
  19.         "buckets":[
    
  20.            {
    
  21.               "key":27380,
    
  22.               "doc_count":311352,
    
  23.               "dim-2":{
    
  24.                  "buckets":[
    
  25.                     {
    
  26.                        "key":1,
    
  27.                        "doc_count":275581,
    
  28.                        "statsField":{
    
  29.                           "count":275581,
    
  30.                           "min":245,
    
  31.                           "max":1295001,
    
  32.                           "avg":111170.57729999075,
    
  33.                           "sum":30636498862.908752
    
  34.                        }
    
  35.                     },
    
  36.                     {
    
  37.                        "key":2,
    
  38.                        "doc_count":35771,
    
  39.                        "statsField":{
    
  40.                           "count":35771,
    
  41.                           "min":300,
    
  42.                           "max":2070000,
    
  43.                           "avg":288086.52814757434,
    
  44.                           "sum":10305143198.366882
    
  45.                        }
    
  46.                     }
    
  47.                  ]
    
  48.               }
    
  49.            },
    
  50.            {
    
  51.               "key":1595,
    
  52.               "doc_count":269090,
    
  53.               "dim-2":{
    
  54.                  "buckets":[
    
  55.                     {
    
  56.                        "key":1,
    
  57.                        "doc_count":221705,
    
  58.                        "statsField":{
    
  59.                           "count":221705,
    
  60.                           "min":180,
    
  61.                           "max":3450000,
    
  62.                           "avg":69082.0294308078,
    
  63.                           "sum":15315831334.957245
    
  64.                        }
    
  65.                     },
    
  66.                     {
    
  67.                        "key":2,
    
  68.                        "doc_count":47385,
    
  69.                        "statsField":{
    
  70.                           "count":47385,
    
  71.                           "min":250,
    
  72.                           "max":6000000,
    
  73.                           "avg":298778.0619758563,
    
  74.                           "sum":14157598466.725952
    
  75.                        }
    
  76.                     }
    
  77.                  ]
    
  78.               }
    
  79.            }
    
  80.         ]
    
  81.      }
    
  82.   }
    
  83. }
  84. }

How can I successfully serialize aggregations result ?

--
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 elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/61d79a3a-6fcd-458a-8e24-76e25ac4810d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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, lpouget@yanport.com (lpouget@yanport.com) 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,
"avg":288086.52814757434,
"sum":10305143198.366882
}
}
]
}
},
{
"key":1595,
"doc_count":269090,
"dim-2":{
"buckets":[
{
"key":1,
"doc_count":221705,
"statsField":{
"count":221705,
"min":180,
"max":3450000,
"avg":69082.0294308078,
"sum":15315831334.957245
}
},
{
"key":2,
"doc_count":47385,
"statsField":{
"count":47385,
"min":250,
"max":6000000,
"avg":298778.0619758563,
"sum":14157598466.725952
}
}
]
}
}
]
}
}
}
}

How can I successfully serialize aggregations result ?

--
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 elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/61d79a3a-6fcd-458a-8e24-76e25ac4810d%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 elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/etPan.54199263.6590700b.3c6%40MacBook-Air-de-David.local.
For more options, visit https://groups.google.com/d/optout.

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 https://twitter.com/dadoonet | @elasticsearchfr
https://twitter.com/elasticsearchfr

Le 17 septembre 2014 à 11:57:24, lpo...@yanport.com <javascript:> (
lpo...@yanport.com <javascript:>) 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 :

  1. {
    2. "size": 0,
    3. "aggregations": {
    4. "agg": {
    5. "global": {},
    6. "aggregations": {
    7. "dim-1": {
    8. "terms": {
    9. "field": "field-1"
    10. },
    11. "aggregations": {
    12. "dim-2": {
    13. "terms": {
    14. "field": "field-2"
    15. },
    16. "aggregations": {
    17. "myStats": {
    18. "stats": {
    19. "field": "statsField"
    20. }
    21. }
    22. }
    23. }
    24. }
    25. }
    26. }
    27. }
    28. }
    29. }

with this response :

  1. {
    2. "took":15932,
    3. "timed_out":false,
    4. "_shards":{
    5. "total":2,
    6. "successful":2,
    7. "failed":0
    8. },
    9. "hits":{
    10. "total":38376901,
    11. "max_score":0,
    12. "hits":[
    13.
    14. ]
    15. },
    16. "aggregations":{
    17. "agg":{
    18. "doc_count":38376901,
    19. "dim-1":{
    20. "buckets":[
    21. {
    22. "key":27380,
    23. "doc_count":311352,
    24. "dim-2":{
    25. "buckets":[
    26. {
    27. "key":1,
    28. "doc_count":275581,
    29. "statsField":{
    30. "count":275581,
    31. "min":245,
    32. "max":1295001,
    33. "avg":111170.57729999075,
    34. "sum":30636498862.908752
    35. }
    36. },
    37. {
    38. "key":2,
    39. "doc_count":35771,
    40. "statsField":{
    41. "count":35771,
    42. "min":300,
    43. "max":2070000,
    44. <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 elasticsearch+unsubscribe@googlegroups.com.
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.

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, lpouget@yanport.com (lpouget@yanport.com) 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, lpo...@yanport.com (lpo...@yanport.com) 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 elasticsearch+unsubscribe@googlegroups.com.
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 elasticsearch+unsubscribe@googlegroups.com.
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.