# Import only arrays that match conditions in Elastic Search

**URL:** <https://discuss.elastic.co/t/import-only-arrays-that-match-conditions-in-elastic-search/199899>\
**Category:** Elasticsearch\
**Created:** [September 18, 2019, 2:15am UTC](https://discuss.elastic.co/t/import-only-arrays-that-match-conditions-in-elastic-search/199899 "2019-09-18T02:15:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![111211](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/111211/32/54366_2.png) [@111211](https://discuss.elastic.co/u/111211)\
**Post date:** [September 18, 2019, 2:15am UTC](https://discuss.elastic.co/t/import-only-arrays-that-match-conditions-in-elastic-search/199899/1 "2019-09-18T02:15:06Z")

</div>

I'm dealing with nested nested data in ElasticSearch.

I want it to work like a SELECT \* from where in an RDBMS.

If you have the following data

```
POST test-stack/test/1234_5678
{
  "Id" : 1234,
  "availables":[
    {
      "Id" : 4444,
      "date" : "2019-09-10",
      "time" : [
        {
          "dateTime" : "2019-09-10T09:30:00+09:00",
          "Count" : 50
        },
        {
          "dateTime" : "2019-09-10T10:00:00+09:00",
          "Count" : 50
        },
        {
          "dateTime" : "2019-09-10T10:30:00+09:00",
          "Count" : 50
        }
      ]
    },
    {
      "Id" : 5555,
      "date" : "2019-09-11",
      "time" : [
        {
          "dateTime" : "2019-09-11T09:30:00+09:00",
          "Count" : 50
        },
        {
          "dateTime" : "2019-09-11T10:00:00+09:00",
          "Count" : 50
        },
        {
          "dateTime" : "2019-09-11T10:30:00+09:00",
          "Count" : 50
        }
      ]
    },
    {
      "Id" : 6666,
      "date" : "2019-09-12",
      "time" : [
        {
          "dateTime" : "2019-09-12T09:30:00+09:00",
          "Count" : 50
        },
        {
          "dateTime" : "2019-09-12T10:00:00+09:00",
          "Count" : 50
        },
        {
          "dateTime" : "2019-09-12T10:30:00+09:00",
          "Count" : 50
        }
      ]
    }
  ]
}

```

If I do this,

Select \* from test t where t.availables.date = '2019-09-10';

So, I want to get this answer,

```
  "Id" : 4444,
  "date" : "2019-09-10",
  "time" : [
    {
      "dateTime" : "2019-09-10T09:30:00+09:00",
      "Count" : 50
    },
    {
      "dateTime" : "2019-09-10T10:00:00+09:00",
      "Count" : 50
    },
    {
      "dateTime" : "2019-09-10T10:30:00+09:00",
      "Count" : 50
    }
  ]

```

I'm a beginner in Elastic Search and I wonder if this is possible in Elastic Search.

I've studied painless scripts but still don't know.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [September 19, 2019, 1:43pm UTC](https://discuss.elastic.co/t/import-only-arrays-that-match-conditions-in-elastic-search/199899/2 "2019-09-19T13:43:41Z")

</div>

Take a look at the [nested datatype](https://www.elastic.co/guide/en/elasticsearch/reference/7.3/nested.html) as well as [inner\_hits](https://www.elastic.co/guide/en/elasticsearch/reference/7.3/search-request-body.html#request-body-search-inner-hits)

---

<div class="post-metadata">

**Author:** ![111211](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/111211/32/54366_2.png) [@111211](https://discuss.elastic.co/u/111211)\
**Post date:** [September 20, 2019, 1:24am UTC](https://discuss.elastic.co/t/import-only-arrays-that-match-conditions-in-elastic-search/199899/3 "2019-09-20T01:24:07Z")

</div>

Thank you so much!!! It is what I was looking for!

---

<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:** [October 18, 2019, 1:24am UTC](https://discuss.elastic.co/t/import-only-arrays-that-match-conditions-in-elastic-search/199899/4 "2019-10-18T01:24:16Z")

</div>

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