# Creating an index on a repeated nested field

**URL:** https://forums.foundationdb.org/t/creating-an-index-on-a-repeated-nested-field/1988
**Category:** Record Layer
**Created:** [February 27, 2020, 7:42pm UTC](https://forums.foundationdb.org/t/creating-an-index-on-a-repeated-nested-field/1988 "2020-02-27T19:42:48Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![dmitrig01](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/dmitrig01/32/791_2.png) [@dmitrig01](https://forums.foundationdb.org/u/dmitrig01)
#### Post date: [February 27, 2020, 7:42pm UTC](https://forums.foundationdb.org/t/creating-an-index-on-a-repeated-nested-field/1988/1 "2020-02-27T19:42:48Z")

</div>

Hi! I have the following record definition:

```auto
message TopLevel {
  repeated Nested nested = 1;
}
message Nested {
  optional string val = 1;
}

```

How do I create an concat index on TopLevel’s `nested.val`?

I.e., if I had a record `{nested: [{val: 1}, {val: 2}]}`, I want an index that has a single entry, `[1, 2]`.

---

<div class="post-metadata">

### Author: ![scgray](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/scgray/32/30_2.png) [@scgray](https://forums.foundationdb.org/u/scgray)
#### Post date: [March 2, 2020, 12:30pm UTC](https://forums.foundationdb.org/t/creating-an-index-on-a-repeated-nested-field/1988/2 "2020-03-02T12:30:07Z")

</div>

I believe this should be an index defined as:

```
Key.Expressions.field("nested", FanType.Concatenate).nest("val")
```
