# SearchParseException: no mapping found

**URL:** <https://discuss.elastic.co/t/searchparseexception-no-mapping-found/48590>\
**Category:** Elasticsearch\
**Created:** [April 27, 2016, 7:59pm UTC](https://discuss.elastic.co/t/searchparseexception-no-mapping-found/48590 "2016-04-27T19:59:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vchav73](https://avatars.discourse-cdn.com/v4/letter/v/f475e1/32.png) [@vchav73](https://discuss.elastic.co/u/vchav73)\
**Post date:** [April 27, 2016, 7:59pm UTC](https://discuss.elastic.co/t/searchparseexception-no-mapping-found/48590/1 "2016-04-27T19:59:23Z")

</div>

I have a script which indexes a document using the the following mapping:

```
{
    "mappings": {
        "rule-check-result": {
            "properties": {
                "date": {
                    "type": "date",
                    "format": "epoch_second"
                },
                "rule": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "alert": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "level": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "sms": {
                    "type": "string"
                },
                "subject": {
                    "type": "string"
                },
                "body": {
                    "type": "string"
                }
            }
        }
    }
}

```

As part of the indexing, the script runs this search:

```
{
    "from": 0,
    "size": 1,
    "query": {
        "filtered": {
            "query": {
                "match_all": {}
            },
            "filter": {
                "and": [
                    {
                        "term": {
                            "rule": "Replication"
                        }
                    },
                    {
                        "term": {
                            "alert": "Replication Lag"
                        }
                    }
                ]
            }
        }
    },
    "sort": {
        "date": {
            "order": "desc"
        }
    }
}

```

When I run the script I get the following in /var/log/elasticsearch/elasticsearch.log:

```
SearchParseException[No mapping found for [date] in order to sort on];
Caused by: SearchParseException[failed to parse search source [{
    "from": 0,
    "size": 1,
    "query": {
        "filtered": {
            "query": {
                "match_all": {}
            },
            "filter": {
                "and": [
                    {
                        "term": {
                            "rule": "Replication"
                        }
                    },
                    {
                        "term": {
                            "alert": "Replication Lag"
                        }
                    }
                ]
            }
        }
    },
    "sort": {
        "date": {
            "order": "desc"
        }
    }
}]]; 

```

Despite the exception the search actually does return a result.

I have two questions about this:

1. Why is this exception generated even though the date field is clearly in the mapping?
2. Why does the search return a result even though an exception is generated?

---

<div class="post-metadata">

**Author:** ![cbuescher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cbuescher/32/60402_2.png) [@cbuescher](https://discuss.elastic.co/u/cbuescher)\
**Post date:** [April 27, 2016, 8:22pm UTC](https://discuss.elastic.co/t/searchparseexception-no-mapping-found/48590/2 "2016-04-27T20:22:58Z")

</div>

Hi,

is it possible that the search you running as part of the indexing hits more than one indes, either through wildcards or an alias? If any of this indices hasn't got the `date` field mapped you will get that exception. The search still returns hits from the index in which the `date` field is correctly mapped, the other indices that don't have that mapping will throw the error.

---

<div class="post-metadata">

**Author:** ![vchav73](https://avatars.discourse-cdn.com/v4/letter/v/f475e1/32.png) [@vchav73](https://discuss.elastic.co/u/vchav73)\
**Post date:** [April 27, 2016, 8:33pm UTC](https://discuss.elastic.co/t/searchparseexception-no-mapping-found/48590/3 "2016-04-27T20:33:26Z")

</div>

That was it. I narrowed the search to the particular index I'm using and it works fine now.

Thanks!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 10:55pm UTC](https://discuss.elastic.co/t/searchparseexception-no-mapping-found/48590/4 "2017-07-05T22:55:45Z")

</div>


