# Search specific offset value of array type

**URL:** <https://discuss.elastic.co/t/search-specific-offset-value-of-array-type/69123>\
**Category:** Elasticsearch\
**Created:** [December 15, 2016, 7:27am UTC](https://discuss.elastic.co/t/search-specific-offset-value-of-array-type/69123 "2016-12-15T07:27:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![no\_jihun](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/no_jihun/32/64028_2.png) [@no\_jihun](https://discuss.elastic.co/u/no_jihun)\
**Post date:** [December 15, 2016, 7:27am UTC](https://discuss.elastic.co/t/search-specific-offset-value-of-array-type/69123/1 "2016-12-15T07:27:36Z")

</div>

I have a index have such mapping

```
{
  "band": {
    "properties": {
      "device_id": {
        "type": "string"
      },
      "sac": {
        "type": "string"
      },
      "session_no": {
        "type": "long"
      },
      "interval": {
        "type": "long"
      },
      "sac_next": {
        "type": "string"
      },
      "sac_prev": {
        "type": "string"
      },
      "timestamp": {
        "type": "long"
      }
    }
  }
}

```

And there are documents like.

```
{
  "_index": "jpl_eventflow_test",
  "_type": "xxx",
  "_id": "AVkBSy0IDdRbCudoQaO4",
  "_score": 1,
  "_source": {
    "device_id": "96D1B243-FE54-480B-AC9D-A3650B0E00FF",
    "interval": 2,
    "timestamp": 1481657475,
    "session_no": 0,
    "sac_prev": [
      "news",
      "posts",
      "posts"
    ],
    "sac": "news",
    "sac_next": [
      "news_item",
      "post_detail", // <---- want to search documents that second of elements having 'post_detail' value.
      "post_detail"
    ]
  }
}

```

So, How can I search documents which sac\_next[1]:"post\_detail" ?  
I mean want to search value not only field but also array offset targeted.

---

<div class="post-metadata">

**Author:** ![no\_jihun](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/no_jihun/32/64028_2.png) [@no\_jihun](https://discuss.elastic.co/u/no_jihun)\
**Post date:** [December 16, 2016, 4:58am UTC](https://discuss.elastic.co/t/search-specific-offset-value-of-array-type/69123/2 "2016-12-16T04:58:40Z")

</div>

I think the answer of this question is here.

> **[Arrays | Elasticsearch Guide \[8.11\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/array.html)**

It says

> Arrays of objects  
> Arrays of objects do not work as you would expect: you cannot query each object independently of the other objects in the array. If you need to be able to do this then you should use the nested datatype instead of the object datatype.

> This is explained in more detail in Nested datatype.

---

<div class="post-metadata">

**Author:** ![Glen\_Smith](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/glen_smith/32/111656_2.png) [@Glen\_Smith](https://discuss.elastic.co/u/Glen_Smith)\
**Post date:** [December 16, 2016, 6:29am UTC](https://discuss.elastic.co/t/search-specific-offset-value-of-array-type/69123/3 "2016-12-16T06:29:30Z")

</div>

There isn't positional information indexed about arrays. Nesting doesn't change that.

In order to search by both position and value, you'll have to enrich your data to explicitly include those.

---

<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 13, 2017, 6:29am UTC](https://discuss.elastic.co/t/search-specific-offset-value-of-array-type/69123/4 "2017-01-13T06:29:48Z")

</div>

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