# Query to select an elasticsearch field which is not part of ES mapping

**URL:** https://community.dremio.com/t/query-to-select-an-elasticsearch-field-which-is-not-part-of-es-mapping/2701
**Category:** Uncategorized
**Created:** [February 5, 2019, 7:17pm UTC](https://community.dremio.com/t/query-to-select-an-elasticsearch-field-which-is-not-part-of-es-mapping/2701 "2019-02-05T19:17:15Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![igreg](https://avatars.discourse-cdn.com/v4/letter/i/bcef8e/32.png) [@igreg](https://community.dremio.com/u/igreg)
#### Post date: [February 5, 2019, 7:17pm UTC](https://community.dremio.com/t/query-to-select-an-elasticsearch-field-which-is-not-part-of-es-mapping/2701/1 "2019-02-05T19:17:15Z")

</div>

I’m querying an elasticsearch index and extracting a field from a JSON tructure (product.details.price) for which there is no corresponding elasticsearch mapping. i.e The field uses elasticsearch dynamic mapping. In addition this field value can also be null. Below is an example:

**In elasticsearch:**

{  
“\_index”: “myIndex”,  
“\_type”: “data”,  
“\_id”: “myIndex\_20180925141725\_5524\_1\_000000070”,  
“\_score”: 1.0,  
“\_source”: {  
“product”: {  
“details”: {  
“price”: null  
}  
}  
}  
}

**Dremio query:**

_SELECT product.details.price as price FROM ES.myindex_

Dremio shows an error: “Unable to find the referenced field: [product.details.price].”

I’ve tried using the a “CASE” statement and a COALESCE function to populate an empty value for the column if the field is null however the same error is thrown in both cases.

eg:  
SELECT COALESCE(product.details.price, ‘’) as price FROM ES.myindex

SELECT CASE WHEN product.details.price IS NULL THEN ‘’ ELSE product.details.price END as price FROM ES.myindex

Is there a way create a virtual dataset which includes nullable fields and fields that are not part of elasticsearch mapping?
