# Query doesn't have any hits with date condition

**URL:** <https://discuss.elastic.co/t/query-doesnt-have-any-hits-with-date-condition/212492>\
**Category:** Elasticsearch\
**Created:** [December 19, 2019, 1:03pm UTC](https://discuss.elastic.co/t/query-doesnt-have-any-hits-with-date-condition/212492 "2019-12-19T13:03:56Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![bingchuan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bingchuan/32/59703_2.png) [@bingchuan](https://discuss.elastic.co/u/bingchuan)\
**Post date:** [December 19, 2019, 1:03pm UTC](https://discuss.elastic.co/t/query-doesnt-have-any-hits-with-date-condition/212492/1 "2019-12-19T13:03:56Z")

</div>

Hi everyone, I'm beginner and i have a question. I created a index which contains some documents. But there are no any hits when i search the documents with the below query.

 ![TIM图片20191219205130](https://us1.discourse-cdn.com/elastic/original/3X/0/2/02ad259e4bd72bcc996b7412bd1f3d0bb5a6773b.png)

Then, I deleted the date condition,and the below screenshot is the result of the new query.  
so,why i can't use the range?

 ![before](https://us1.discourse-cdn.com/elastic/original/3X/6/e/6eb137b35063c412045073bbebbb05ed1483327c.png)

this is mappings

> {  
> "mapping": {  
> "properties": {  
> "bf\_info": {  
> "type": "text"  
> },  
> "build": {  
> "type": "text"  
> },  
> "deviceName": {  
> "type": "text"  
> },  
> "deviceType": {  
> "type": "text"  
> },  
> "deviceUniqueIdentifier": {  
> "type": "text"  
> },  
> "doc": {  
> "properties": {  
> "bf\_info": {  
> "type": "text",  
> "fields": {  
> "keyword": {  
> "type": "keyword",  
> "ignore\_above": 256  
> }  
> }  
> },  
> "build": {  
> "type": "text",  
> "fields": {  
> "keyword": {  
> "type": "keyword",  
> "ignore\_above": 256  
> }  
> }  
> },  
> "deviceName": {  
> "type": "text",  
> "fields": {  
> "keyword": {  
> "type": "keyword",  
> "ignore\_above": 256  
> }  
> }  
> },  
> "deviceType": {  
> "type": "text",  
> "fields": {  
> "keyword": {  
> "type": "keyword",  
> "ignore\_above": 256  
> }  
> }  
> },  
> "deviceUniqueIdentifier": {  
> "type": "text",  
> "fields": {  
> "keyword": {  
> "type": "keyword",  
> "ignore\_above": 256  
> }  
> }  
> },  
> "graphicsDeviceName": {  
> "type": "text",  
> "fields": {  
> "keyword": {  
> "type": "keyword",  
> "ignore\_above": 256  
> }  
> }  
> },  
> "graphicsDeviceVendor": {  
> "type": "text",  
> "fields": {  
> "keyword": {  
> "type": "keyword",  
> "ignore\_above": 256  
> }  
> }  
> },  
> "graphicsMemorySize": {  
> "type": "text",  
> "fields": {  
> "keyword": {  
> "type": "keyword",  
> "ignore\_above": 256  
> }  
> }  
> },  
> "graphicsPixelFillrate": {  
> "type": "text",  
> "fields": {  
> "keyword": {  
> "type": "keyword",  
> "ignore\_above": 256  
> }  
> }  
> },  
> "id": {  
> "type": "long"  
> },  
> "language": {  
> "type": "text",  
> "fields": {  
> "keyword": {  
> "type": "keyword",  
> "ignore\_above": 256  
> }  
> }  
> },  
> "loadedLevelName": {  
> "type": "text",  
> "fields": {  
> "keyword": {  
> "type": "keyword",  
> "ignore\_above": 256  
> }  
> }  
> },  
> "maxTextureSize": {  
> "type": "text",  
> "fields": {  
> "keyword": {  
> "type": "keyword",  
> "ignore\_above": 256  
> }  
> }  
> },  
> "message": {  
> "type": "text",  
> "fields": {  
> "keyword": {  
> "type": "keyword",  
> "ignore\_above": 256  
> }  
> }  
> },  
> "operatingSystem": {  
> "type": "text",  
> "fields": {  
> "keyword": {  
> "type": "keyword",  
> "ignore\_above": 256  
> }  
> }  
> },  
> "platform": {  
> "type": "text",  
> "fields": {  
> "keyword": {  
> "type": "keyword",  
> "ignore\_above": 256  
> }  
> }  
> },  
> "playerId": {  
> "type": "text",  
> "fields": {  
> "keyword": {  
> "type": "keyword",  
> "ignore\_above": 256  
> }  
> }  
> },  
> "processorCount": {  
> "type": "text",  
> "fields": {  
> "keyword": {  
> "type": "keyword",  
> "ignore\_above": 256  
> }  
> }  
> },  
> "processorType": {  
> "type": "text",  
> "fields": {  
> "keyword": {  
> "type": "keyword",  
> "ignore\_above": 256  
> }  
> }  
> },  
> "resolutionHeight": {  
> "type": "text",  
> "fields": {  
> "keyword": {  
> "type": "keyword",  
> "ignore\_above": 256  
> }  
> }  
> },  
> "resolutionWidth": {  
> "type": "text",  
> "fields": {  
> "keyword": {  
> "type": "keyword",  
> "ignore\_above": 256  
> }  
> }  
> },  
> "serverIP": {  
> "type": "text",  
> "fields": {  
> "keyword": {  
> "type": "keyword",  
> "ignore\_above": 256  
> }  
> }  
> },  
> "serverId": {  
> "type": "text",  
> "fields": {  
> "keyword": {  
> "type": "keyword",  
> "ignore\_above": 256  
> }  
> }  
> },  
> "server\_date": {  
> "type": "text",  
> "fields": {  
> "keyword": {  
> "type": "keyword",  
> "ignore\_above": 256  
> }  
> }  
> },  
> "stack": {  
> "type": "text",  
> "fields": {  
> "keyword": {  
> "type": "keyword",  
> "ignore\_above": 256  
> }  
> }  
> },  
> "systemMemorySize": {  
> "type": "text",  
> "fields": {  
> "keyword": {  
> "type": "keyword",  
> "ignore\_above": 256  
> }  
> }  
> },  
> "timestamp": {  
> "type": "text",  
> "fields": {  
> "keyword": {  
> "type": "keyword",  
> "ignore\_above": 256  
> }  
> }  
> },  
> "unityVersion": {  
> "type": "text",  
> "fields": {  
> "keyword": {  
> "type": "keyword",  
> "ignore\_above": 256  
> }  
> }  
> },  
> "version": {  
> "type": "text",  
> "fields": {  
> "keyword": {  
> "type": "keyword",  
> "ignore\_above": 256  
> }  
> }  
> }  
> }  
> },  
> "graphicsDeviceName": {  
> "type": "text"  
> },  
> "graphicsDeviceVendor": {  
> "type": "text"  
> },  
> "graphicsMemorySize": {  
> "type": "text"  
> },  
> "graphicsPixelFillrate": {  
> "type": "text"  
> },  
> "id": {  
> "type": "integer"  
> },  
> "language": {  
> "type": "text"  
> },  
> "loadedLevelName": {  
> "type": "text"  
> },  
> "maxTextureSize": {  
> "type": "text"  
> },  
> "message": {  
> "type": "text"  
> },  
> "operatingSystem": {  
> "type": "text"  
> },  
> "platform": {  
> "type": "text"  
> },  
> "playerId": {  
> "type": "text"  
> },  
> "processorCount": {  
> "type": "text"  
> },  
> "processorType": {  
> "type": "text"  
> },  
> "resolutionHeight": {  
> "type": "text"  
> },  
> "resolutionWidth": {  
> "type": "text"  
> },  
> "serverIP": {  
> "type": "text"  
> },  
> "serverId": {  
> "type": "text"  
> },  
> "server\_date": {  
> "type": "date",  
> "format": "yyyy-MM-dd HH:mm:ss"  
> },  
> "stack": {  
> "type": "text"  
> },  
> "systemMemorySize": {  
> "type": "text"  
> },  
> "timestamp": {  
> "type": "integer"  
> },  
> "unityVersion": {  
> "type": "text"  
> },  
> "version": {  
> "type": "text"  
> }  
> }  
> }  
> }

---

<div class="post-metadata">

**Author:** ![Bernt\_Rostad](https://avatars.discourse-cdn.com/v4/letter/b/3ab097/32.png) [@Bernt\_Rostad](https://discuss.elastic.co/u/Bernt_Rostad)\
**Post date:** [December 19, 2019, 1:35pm UTC](https://discuss.elastic.co/t/query-doesnt-have-any-hits-with-date-condition/212492/2 "2019-12-19T13:35:41Z")

</div>

> [@bingchuan](#):
>
> "server\_date": {  
> "type": "text",  
> "fields": {  
> "keyword": {  
> "type": "keyword",  
> "ignore\_above": 256  
> }

In your mapping you've set server\_date to "type": "text" which I doubt will work with your range query, instead you should set it so something like this:

```
"server_date": {
   "type": "date",
   "format": "strict_date_optional_time"
},

```

That's the mapping I use and it allows me to perform range queries on date.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [December 19, 2019, 3:22pm UTC](https://discuss.elastic.co/t/query-doesnt-have-any-hits-with-date-condition/212492/3 "2019-12-19T15:22:49Z")

</div>

Welcome!

Please don't post images of text as they are hard to read, may not display correctly for everyone, and are not searchable.

Instead, paste the text and format it with `</>` icon or pairs of triple backticks (```), and check the preview window to make sure it's properly formatted before posting it. This makes it more likely that your question will receive a useful answer.

---

<div class="post-metadata">

**Author:** ![bingchuan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bingchuan/32/59703_2.png) [@bingchuan](https://discuss.elastic.co/u/bingchuan)\
**Post date:** [December 20, 2019, 2:57am UTC](https://discuss.elastic.co/t/query-doesnt-have-any-hits-with-date-condition/212492/4 "2019-12-20T02:57:44Z")

</div>

Thank you, I will check my mappings and correct it.

---

<div class="post-metadata">

**Author:** ![bingchuan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bingchuan/32/59703_2.png) [@bingchuan](https://discuss.elastic.co/u/bingchuan)\
**Post date:** [December 20, 2019, 2:58am UTC](https://discuss.elastic.co/t/query-doesnt-have-any-hits-with-date-condition/212492/5 "2019-12-20T02:58:50Z")

</div>

sorry. I will rewrite it.

---

<div class="post-metadata">

**Author:** ![bingchuan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bingchuan/32/59703_2.png) [@bingchuan](https://discuss.elastic.co/u/bingchuan)\
**Post date:** [December 20, 2019, 7:16am UTC](https://discuss.elastic.co/t/query-doesnt-have-any-hits-with-date-condition/212492/6 "2019-12-20T07:16:14Z")

</div>

Hi, guy, I'm confused. I set the type of "server\_date" as "date" type, but it's not。  
so, maybe I need to set some settings or other?

```auto
PUT /error_log
{
  "mappings" : {
    "properties": {
    "id" : { "type" : "integer" },
    "timestamp" : { "type" : "keyword" },
    "version" : {"type" :"keyword"},
    "build" : {"type" :"keyword"},
    "message" : {"type" :"text"},
    "stack" : {"type" :"text"},
    "platform" : {"type" :"keyword"},
    "serverIP" : {"type" :"keyword"},
    "serverId" : {"type" :"keyword"},
    "playerId" : {"type" :"keyword"},
    "deviceName" : {"type" :"keyword"},
    "deviceType" : {"type" :"keyword"},
    "deviceUniqueIdentifier" : {"type" :"keyword"},
    "operatingSystem" : {"type" :"keyword"},
    "language" : {"type" :"keyword"},
    "systemMemorySize" : {"type" :"keyword"},
    "processorCount" : {"type" :"keyword"},
    "processorType" : {"type" :"keyword"},
    "resolutionWidth" : {"type" :"keyword"},
    "resolutionHeight" : {"type" :"keyword"},
    "graphicsDeviceName" : {"type" :"keyword"},
    "graphicsDeviceVendor" : {"type" :"keyword"},
    "graphicsMemorySize" : {"type" :"keyword"},
    "graphicsPixelFillrate" : {"type" :"keyword"},
    "maxTextureSize" : {"type" :"keyword"},
    "loadedLevelName" : {"type" :"keyword"},
    "unityVersion" : {"type" :"keyword"},
    "bf_info" : {"type": "text"},
    "server_date" : {"type" : "date" , "format" :"yyyy-MM-dd HH:mm:ss"}
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![bingchuan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bingchuan/32/59703_2.png) [@bingchuan](https://discuss.elastic.co/u/bingchuan)\
**Post date:** [December 20, 2019, 7:40am UTC](https://discuss.elastic.co/t/query-doesnt-have-any-hits-with-date-condition/212492/7 "2019-12-20T07:40:52Z")

</div>

Ok, friend, i have found the mistake that I uploaded some incorrect documents.

---

<div class="post-metadata">

**Author:** ![bingchuan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bingchuan/32/59703_2.png) [@bingchuan](https://discuss.elastic.co/u/bingchuan)\
**Post date:** [December 20, 2019, 7:41am UTC](https://discuss.elastic.co/t/query-doesnt-have-any-hits-with-date-condition/212492/8 "2019-12-20T07:41:38Z")

</div>

thank you for your help

---

<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:** [January 17, 2020, 7:41am UTC](https://discuss.elastic.co/t/query-doesnt-have-any-hits-with-date-condition/212492/9 "2020-01-17T07:41:46Z")

</div>

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