# No field found for \[nextDueDate\] in mapping with types \[\]

**URL:** <https://forum.opensearch.org/t/no-field-found-for-nextduedate-in-mapping-with-types/10942>\
**Category:** SQL\
**Created:** [September 15, 2022, 6:53pm UTC](https://forum.opensearch.org/t/no-field-found-for-nextduedate-in-mapping-with-types/10942 "2022-09-15T18:53:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![greg.fenton](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/greg.fenton/32/4222_2.png) [@greg.fenton](https://forum.opensearch.org/u/greg.fenton)\
**Post date:** [September 15, 2022, 6:53pm UTC](https://forum.opensearch.org/t/no-field-found-for-nextduedate-in-mapping-with-types/10942/1 "2022-09-15T18:53:55Z")

</div>

Using the SQL query:

```sql
SELECT *
from dev_entity_policy
where date(nextDueDate) <= curdate()

```

I get back the error:

```auto
"caused_by" : {
        "type" : "illegal_argument_exception",
        "reason" : "No field found for [nextDueDate] in mapping with types []"
    }

```

I know that `nextDueDate` is a field in each doc of the index that contains a datetime (or is it timestamp? – is there a way to get the datatype for a given field?).

Any suggestions on how to properly do an inequality query properly?

---

<div class="post-metadata">

**Author:** ![daichen](https://avatars.discourse-cdn.com/v4/letter/d/c4cdca/32.png) [@daichen](https://forum.opensearch.org/u/daichen)\
**Post date:** [September 21, 2022, 12:32am UTC](https://forum.opensearch.org/t/no-field-found-for-nextduedate-in-mapping-with-types/10942/2 "2022-09-21T00:32:57Z")

</div>

@greg.fenton You can check your index mapping by [Get index - OpenSearch documentation](https://opensearch.org/docs/latest/opensearch/rest-api/index-apis/get-index/). Thanks!

---

<div class="post-metadata">

**Author:** ![greg.fenton](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/greg.fenton/32/4222_2.png) [@greg.fenton](https://forum.opensearch.org/u/greg.fenton)\
**Post date:** [September 22, 2022, 3:40pm UTC](https://forum.opensearch.org/t/no-field-found-for-nextduedate-in-mapping-with-types/10942/3 "2022-09-22T15:40:32Z")

</div>

Hi @daichen !

Are you suggesting that I ensure the `nextDueDate` is defined in the index? Am I supposed to declare the field as being a `date` field?

(Sorry for the newbie questions…I inherited someone else’s project and I’m pretty new to OpenSearch)

---

<div class="post-metadata">

**Author:** ![daichen](https://avatars.discourse-cdn.com/v4/letter/d/c4cdca/32.png) [@daichen](https://forum.opensearch.org/u/daichen)\
**Post date:** [September 22, 2022, 4:13pm UTC](https://forum.opensearch.org/t/no-field-found-for-nextduedate-in-mapping-with-types/10942/4 "2022-09-22T16:13:00Z")

</div>

@greg.fenton No worries! I was suggesting we check the index mapping first by `GET [index]/_mapping` API. Then you will see if there is `nextDueDate` and its type. If everything looks good, please share your steps that we can reproduce, including test index mapping, some data, each request you ran. Because the error message you posted seems not from SQL plugin, it would helpful if you can provide more context. Thanks!

---

<div class="post-metadata">

**Author:** ![greg.fenton](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/greg.fenton/32/4222_2.png) [@greg.fenton](https://forum.opensearch.org/u/greg.fenton)\
**Post date:** [December 6, 2022, 6:40pm UTC](https://forum.opensearch.org/t/no-field-found-for-nextduedate-in-mapping-with-types/10942/5 "2022-12-06T18:40:26Z")

</div>

Sorry for the very tardy reply.

I rebuilt the index and that error was resolved. Seems our first document to include `nextDueDate` did not have a valid date. We are using Dynamic Mapping, so things got confused.
