# Search docs not return 0 hits

**URL:** <https://discuss.elastic.co/t/search-docs-not-return-0-hits/357309>\
**Category:** Elasticsearch\
**Created:** [April 12, 2024, 3:51pm UTC](https://discuss.elastic.co/t/search-docs-not-return-0-hits/357309 "2024-04-12T15:51:43Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![JPXotox](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpxotox/32/133485_2.png) [@JPXotox](https://discuss.elastic.co/u/JPXotox)\
**Post date:** [April 12, 2024, 3:51pm UTC](https://discuss.elastic.co/t/search-docs-not-return-0-hits/357309/1 "2024-04-12T15:51:43Z")

</div>

Hi, I´m trying to search some docs, in Kibana using discover i have 2 hits  
with the following timestamp: @timestamp  
Apr 3, 2024 @ 03:27:23.000 and Apr 3, 2024 @ 03:26:56.000 for a doc with a field "sender": "TEED-NEC455"

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/0/2/021326f2667fec4ff3a768661ce6334a35d5d314.png)

but, when I try using the search API as follows doesn´t bring anything relevant

```auto
{
  "query": {
    "bool": {
      "must": [
        {
          "range": {
            "date": {
              "gte": "2024-04-03T03:25:00Z",
              "lte": "2024-04-03T03:30:00Z"
            }
          }
        },
        {
          "term": {
            "sender": "TEED-NEC455"
          }
        }
      ]
    }
  }
}

```

result I get from the API search:

```auto
{
    "took": 0,
    "timed_out": false,
    "_shards": {
        "total": 1,
        "successful": 1,
        "skipped": 0,
        "failed": 0
    },
    "hits": {
        "total": {
            "value": 0,
            "relation": "eq"
        },
        "max_score": null,
        "hits": []
    }
}

```

Thanks for your help!

---

<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:** [April 12, 2024, 5:23pm UTC](https://discuss.elastic.co/t/search-docs-not-return-0-hits/357309/2 "2024-04-12T17:23:17Z")

</div>

Welcome!

What's the mapping for this index?

---

<div class="post-metadata">

**Author:** ![JPXotox](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpxotox/32/133485_2.png) [@JPXotox](https://discuss.elastic.co/u/JPXotox)\
**Post date:** [April 12, 2024, 6:02pm UTC](https://discuss.elastic.co/t/search-docs-not-return-0-hits/357309/3 "2024-04-12T18:02:08Z")

</div>

This is the mapping:

```auto
{
  "mappings": {
    "properties": {
      "@timestamp": {
        "type": "date"
      },
      "device": {
        "properties": {
          "description": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          }
        }
      },
      "geo": {
        "properties": {
          "location": {
            "type": "geo_point"
          }
        }
      },
      "host": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "identifier": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "index": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "info": {
        "properties": {
          "areas": {
            "properties": {
              "circles": {
                "properties": {
                  "center": {
                    "properties": {
                      "latitude": {
                        "type": "float"
                      },
                      "longitude": {
                        "type": "float"
                      }
                    }
                  },
                  "radius": {
                    "type": "float"
                  }
                }
              },
              "description": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              }
            }
          },
          "category": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "certainty": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "direction": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "effective": {
            "type": "date"
          },
          "event": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "expires": {
            "type": "date"
          },
          "infodescription": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "language": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "objectid": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "objecttype": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "parameters": {
            "type": "nested",
            "properties": {
              "BRAND": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "CAMERAID": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "CAMERANAME": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "COLOUR": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "COUNTRY": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "CSAI_APP_VALIDATIONS": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "CUSTOMINFO": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "DEVICEID": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "DEVICEPROVIDER": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "DEVICETYPE": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "DIRECTION": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "EFFECTIVE": {
                "type": "date"
              },
              "EQUIPMENTTYPE": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "EXTERNALEVENTID": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "IMAGEHEIGHT": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "IMAGELEFT": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "IMAGETOP": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "IMAGEWIDTH": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "LATITUDE": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "LONGITUDE": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "OBJECTENTITY": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "OBJECTID": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "OBJECTTYPE": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "ORIGINTYPE": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "SCORE": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "SPEED": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "TIMESTAMP": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "VEHICLETYPE": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              }
            }
          },
          "parameters,LATITUDE": {
            "type": "float"
          },
          "parameters,LONGITUDE": {
            "type": "float"
          },
          "sent": {
            "type": "date"
          },
          "severity": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "urgency": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "vehicletype": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          }
        }
      },
      "messagetype": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "scope": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "sender": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "sent": {
        "type": "date"
      },
      "source": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "sourcetype": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "status": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "tenantId": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "time": {
        "type": "long"
      }
    }
  }
}

```

Thanks

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [April 12, 2024, 6:13pm UTC](https://discuss.elastic.co/t/search-docs-not-return-0-hits/357309/4 "2024-04-12T18:13:24Z")

</div>

The search request specifies the time range in UTC time and all timestamps in Elasticsearch are indexed in UTC timezone. Kibana does by default however translate timestamps into the local timezone so your query range may, depending on the timezone you are located in, posibly not match what you have specified in Kibana.

Which timezone are you in?

---

<div class="post-metadata">

**Author:** ![JPXotox](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpxotox/32/133485_2.png) [@JPXotox](https://discuss.elastic.co/u/JPXotox)\
**Post date:** [April 12, 2024, 6:35pm UTC](https://discuss.elastic.co/t/search-docs-not-return-0-hits/357309/5 "2024-04-12T18:35:43Z")

</div>

I Christian,  
my timezone is GMT-3.  
I tried to set the filter with +3 like this:

```auto
 "range": {
            "date": {
              "gte": "2024-04-03T06:25:00Z",
              "lte": "2024-04-03T06:30:00Z"
            }
          }

```

but It didn´t work, so I´m doing something wrong 😔

```auto
{
    "took": 0,
    "timed_out": false,
    "_shards": {
        "total": 1,
        "successful": 1,
        "skipped": 0,
        "failed": 0
    },
    "hits": {
        "total": {
            "value": 0,
            "relation": "eq"
        },
        "max_score": null,
        "hits": []
    }
}

```

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [April 12, 2024, 7:09pm UTC](https://discuss.elastic.co/t/search-docs-not-return-0-hits/357309/6 "2024-04-12T19:09:38Z")

</div>

Any chance daylight saving time might play in?

---

<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:** [April 12, 2024, 11:19pm UTC](https://discuss.elastic.co/t/search-docs-not-return-0-hits/357309/7 "2024-04-12T23:19:29Z")

</div>

Change that part of the query:

```
    {
      "term": {
        "sender": "TEED-NEC455"
      }
    }

```

To

```
    {
      "term": {
        "sender.keyword": "TEED-NEC455"
      }
    }

```

You might also have to fix the date as @Christian_Dahlqvist said

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [April 13, 2024, 12:15am UTC](https://discuss.elastic.co/t/search-docs-not-return-0-hits/357309/8 "2024-04-13T00:15:12Z")

</div>

Are you sure you are using the correct date field?

The mapping you shared does not have a field named `date`, so you do not have this field in your index.

You need to use an existing date field like `@timestamp` or `info.effective` for example, those fields are date fields that exists in your index, but you do not have any field named `date`.

Try this:

```auto
{
  "query": {
    "bool": {
      "must": [
        {
          "range": {
            "info.effective": {
              "gte": "2024-04-03T03:25:00Z",
              "lte": "2024-04-03T03:30:00Z"
            }
          }
        },
        {
          "term": {
            "sender": "TEED-NEC455"
          }
        }
      ]
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [April 13, 2024, 6:41am UTC](https://discuss.elastic.co/t/search-docs-not-return-0-hits/357309/9 "2024-04-13T06:41:23Z")

</div>

> [@JPXotox](#):
>
> ```auto
> "range": {
> "date": {
> "gte": "2024-04-03T06:25:00Z",
> "lte": "2024-04-03T06:30:00Z"
> }
> }
> 
> ```

Kibana filter based on the `@timestamp` field by default, so unless you have overridden this you should probably change your range clause as follows:

```auto
"range": {
            "@timestamp": {
              "gte": "2024-04-03T06:25:00Z",
              "lte": "2024-04-03T06:30:00Z"
            }
          }

```

---

<div class="post-metadata">

**Author:** ![JPXotox](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpxotox/32/133485_2.png) [@JPXotox](https://discuss.elastic.co/u/JPXotox)\
**Post date:** [April 15, 2024, 1:23pm UTC](https://discuss.elastic.co/t/search-docs-not-return-0-hits/357309/10 "2024-04-15T13:23:09Z")

</div>

yep! I was setting wrong the time field,  
so I changed it to this way:

```auto
{
  //"size": 42,
  "query": {
    "bool": {
      "must": [
        {
          "range": {
            "info.effective": {
              "gte": "2024-04-10T21:55:00-03:00",
              "lte": "2024-04-10T21:59:00-03:00"
            }
          }
        },
        {
          "match": {
            "sender": "TEED-NEC455"
          }
        }
      ]
    }
  }
}

```

and works like a charm! 😃

---

<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:** [May 13, 2024, 1:23pm UTC](https://discuss.elastic.co/t/search-docs-not-return-0-hits/357309/11 "2024-05-13T13:23:36Z")

</div>

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