0

Sorry for duplicated question, but this does not seem to work with current Elastic Search 2.x version. Basically, I use NEST to send query to ES and would like to get response as plain JSON, just like using POST command on Sense. Similar problem exists here: Returning Raw Json in ElasticSearch NEST query

Results retrieved using:

var searchResult = _elasticClient.LowLevel.Search<SearchResponse<SearchResult>>(querytEST);

Result wanted:

{
  "took": 406,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "failed": 0
  },
  "hits": {
    "total": 14,
    "max_score": 0,
    "hits": []
  },
  "aggregations": {
    "query": {
      "doc_count_error_upper_bound": 0,
      "sum_other_doc_count": 1,
      "buckets": [
        {
          "key": "laura",
          "doc_count": 14,
          "top": {
            "hits": {
              "total": 14,
              "max_score": 4.1078563,
              "hits": [
                {...
Community
  • 1
  • 1
ProgLearner
  • 171
  • 2
  • 15

1 Answers1

1

The type T passed to .Search<T> on the low level client specifies the return type of the result. In order to get json returned, you simply need to change this to string

var searchResult = _elasticClient.LowLevel.Search<string>(querytEST);
Russ Cam
  • 124,184
  • 33
  • 204
  • 266