# Lua error when creating storage index

**URL:** <https://forum.heroiclabs.com/t/lua-error-when-creating-storage-index/4467>\
**Category:** Runtime Framework\
**Tags:** lua\
**Created:** [October 16, 2023, 5:26pm UTC](https://forum.heroiclabs.com/t/lua-error-when-creating-storage-index/4467 "2023-10-16T17:26:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anteaters](https://avatars.discourse-cdn.com/v4/letter/a/7bcc69/32.png) [@anteaters](https://forum.heroiclabs.com/u/anteaters)\
**Post date:** [October 16, 2023, 5:26pm UTC](https://forum.heroiclabs.com/t/lua-error-when-creating-storage-index/4467/1 "2023-10-16T17:26:23Z")

</div>

I’m trying to add an index on my collections but even the code provided in the documentation fails. When I try this code

```auto
local nk = require("nakama")

local name = "IndexName"
local collection = "CollectionName"
local key = "KeyName"
local fields = {"field1", "field2"} -- Only objects containing any of these keys and respective values are indexed.
local maxEntries = 1000

local err = nk.register_storage_index(name, collection, key, fields, maxEntries)

```

It fails with

```auto
{"level":"fatal","ts":"2023-10-16T17:25:06.904Z","caller":"main.go:158","msg":"Failed initializing runtime modules","error":"data/modules/test.lua:9: attempt to call a non-function object\nstack traceback:\n\tdata/modules/test.lua:9: in main chunk\n\t[G]: ?"}

```

---

<div class="post-metadata">

**Author:** ![sesposito](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/sesposito/32/2594_2.png) [@sesposito](https://forum.heroiclabs.com/u/sesposito)\
**Post date:** [October 17, 2023, 12:06pm UTC](https://forum.heroiclabs.com/t/lua-error-when-creating-storage-index/4467/2 "2023-10-17T12:06:20Z")

</div>

Hello @anteaters,

What version of Nakama are you running? The Storage Index APIs were introduced in [v3.17.0](https://github.com/heroiclabs/nakama/releases/tag/v3.17.0).

Best.

---

<div class="post-metadata">

**Author:** ![anteaters](https://avatars.discourse-cdn.com/v4/letter/a/7bcc69/32.png) [@anteaters](https://forum.heroiclabs.com/u/anteaters)\
**Post date:** [October 17, 2023, 12:18pm UTC](https://forum.heroiclabs.com/t/lua-error-when-creating-storage-index/4467/3 "2023-10-17T12:18:05Z")

</div>

Oh that explains it. I’m using “3.16.0+27ba93d3” at the moment. I’ll update and see if it works. Good catch, thank you very much.

Switched to “3.17.1+c3b317d8” and it works as it should.
