# Help Searching the data from my index

**URL:** <https://discuss.elastic.co/t/help-searching-the-data-from-my-index/240286>\
**Category:** Elasticsearch\
**Created:** [July 8, 2020, 7:42am UTC](https://discuss.elastic.co/t/help-searching-the-data-from-my-index/240286 "2020-07-08T07:42:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![snowfall\_2010](https://avatars.discourse-cdn.com/v4/letter/s/7cd45c/32.png) [@snowfall\_2010](https://discuss.elastic.co/u/snowfall_2010)\
**Post date:** [July 8, 2020, 7:42am UTC](https://discuss.elastic.co/t/help-searching-the-data-from-my-index/240286/1 "2020-07-08T07:42:11Z")

</div>

my index save data structure is the pic below:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/d/b/db9c5b0e94beefdf640d0c6999b87622a2d49499.png)

index info:

```
"1":{
    "aliases":{},
    "mappings":{
        "properties":{
            "DeviceId":{
                "type":"text",
                "fields":{
                    "keyword":{
                        "type":"keyword",
                        "ignore_above":256
                    }
                }
            },
            "Duration":{
                "type":"text",
                "fields":{
                    "keyword":{
                        "type":"keyword",
                        "ignore_above":256
                    }
                }
            },
            "FileName":{
                "type":"text",
                "fields":{
                    "keyword":{
                        "type":"keyword",
                        "ignore_above":256
                    }
                },
                "fielddata":true
            },
            "Hls":{
                "type":"text",
                "fields":{
                    "keyword":{
                        "type":"keyword",
                        "ignore_above":256
                    }
                }
            },
            "StartAt":{
                "type":"text",
                "fields":{
                    "keyword":{
                        "type":"keyword",
                        "ignore_above":256
                    }
                }
            }
        }
    },
    "settings":{
        "index":{
            "creation_date":"1589015659889",
            "number_of_shards":"1",
            "number_of_replicas":"1",
            "uuid":"JRmRGN7GSpOU4NfrHyTJ_g",
            "version":{
                "created":"7060299"
            },
            "provided_name":"1"
        }
    }
}

```

}

I have a requirement to search the filename field. FileName 's structure is IndexName/YYYYMMDD/hhmmss.m3u8.  
I need to find out which day of the month there is a file name record.

Date infomation is only stored in FileName.

Any Sugguestion?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [July 8, 2020, 9:44pm UTC](https://discuss.elastic.co/t/help-searching-the-data-from-my-index/240286/2 "2020-07-08T21:44:56Z")

</div>

Your best option is to split that out into it's own field.  
You might be able to do that with a script, but that's outside my knowledge sorry.

---

<div class="post-metadata">

**Author:** ![snowfall\_2010](https://avatars.discourse-cdn.com/v4/letter/s/7cd45c/32.png) [@snowfall\_2010](https://discuss.elastic.co/u/snowfall_2010)\
**Post date:** [July 9, 2020, 3:30am UTC](https://discuss.elastic.co/t/help-searching-the-data-from-my-index/240286/3 "2020-07-09T03:30:44Z")

</div>

thx for reply 💓

---

<div class="post-metadata">

**Author:** ![Vinayak\_Sapre](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vinayak_sapre/32/45939_2.png) [@Vinayak\_Sapre](https://discuss.elastic.co/u/Vinayak_Sapre)\
**Post date:** [July 9, 2020, 6:14am UTC](https://discuss.elastic.co/t/help-searching-the-data-from-my-index/240286/4 "2020-07-09T06:14:18Z")

</div>

Snowfall,  
Are you trying to search docs for a specific date or extract unique dates from docs? For later you can use script as suggested by Mark

```auto
{
  "size": 0,
  "aggs": {
    "dates": {
      "terms": {
        "field": "FileName.keyword",
        "script": {
          "source": "int s1 = _value.indexOf('/'); int s2 = _value.indexOf('/', s1+1); _value.substring(s1+1,s2)",
          "lang": "painless"
        }
      }
    }
  }
}

```

---

<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:** [August 6, 2020, 6:14am UTC](https://discuss.elastic.co/t/help-searching-the-data-from-my-index/240286/5 "2020-08-06T06:14:19Z")

</div>

Closed on August 6, 2020, 6:14am UTC

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