Doc_value for numeric field does not match the _source field value

Running Elasticsearch 6.8.0.

I have a field of type float. Here is the mapping:

"constructionCost" : {
     "type" : "float"
 }

It is being populated from a SQL Server decimal(19,4) column.

Here is my query:

GET projects/_search
{
  "aggs": {
    "cost": {
      "terms": {
        "field": "constructionCost"
      }
    }
  }, 
  "_source": "constructionCost", 
  "query": {
    "term": {
      "elastic_id": {
        "value": "xxxxxx"
      }
    }
  }
}

Results:

{
  "took" : 24,
  "timed_out" : false,
  "_shards" : {
    "total" : 3,
    "successful" : 3,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : 1,
    "max_score" : 13.269231,
    "hits" : [
      {
        "_index" : "prjs_5_3_1923_0",
        "_type" : "_doc",
        "_id" : "xxxxxxxx",
        "_score" : 13.269231,
        "_routing" : "xxxxxxxx",
        "_source" : {
          "constructionCost" : 582170.29
        }
      }
    ]
  },
  "aggregations" : {
    "cost" : {
      "doc_count_error_upper_bound" : 0,
      "sum_other_doc_count" : 0,
      "buckets" : [
        {
          "key" : 582170.3125,
          "doc_count" : 1
        }
      ]
    }
  }
}

Why is the value for constructionCost different? The value in the database matches the value in the _source field.

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