Skip to content

Commit

Permalink
Correct syntax and example for setting is_multikey option for functions
Browse files Browse the repository at this point in the history
Part of #2507
  • Loading branch information
veod32 committed Mar 3, 2022
1 parent 6404417 commit 6d13441
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions doc/reference/reference_lua/box_schema/func_create.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ box.schema.func.create()
``true`` means that the function should be deterministic,
``false`` means that the function may or may not be deterministic.

* ``is_multikey`` = ``true|false`` (default = ``false``)---
if ``true`` is set in the function definition for a functional index, the function returns multiple keys.
For details, see the :ref:`example <box_space-index_func_multikey>`.

* ``body`` = function definition (default = nil) - string;
the function definition.

Expand Down
8 changes: 5 additions & 3 deletions doc/reference/reference_lua/box_space/create_index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ On this page:
* :ref:`Allowing null for an indexed key <box_space-is_nullable>`
* :ref:`Creating an index using field names instead of field numbers <box_space-field_names>`
* :ref:`Creating an index using the path option for map fields (JSON-path indexes) <box_space-path>`
* :ref:`Creating an multikey index using the path option with [*] <box_space-path_multikey>`
* :ref:`Creating a multikey index using the path option with [*] <box_space-path_multikey>`
* :ref:`Creating a functional index <box_space-index_func>`

.. class:: space_object
Expand Down Expand Up @@ -638,10 +638,12 @@ Here is the full code of the example:
box.space.tester.index.func_idx:select('w')
box.space.tester.index.func_idx:select(box.func.my_func:call({{'tester', 'wombat'}}));
.. _box_space-index_func_multikey:

Functions for functional indexes can return **multiple keys**. Such functions are
called "multikey" functions.

The ``box.func.create`` options must include ``opts = {is_multikey = true}``.
To create a multikey function, the options of ``box.schema.func.create()`` must include ``is_multikey = true``.
The return value must be a table of tuples. If a multikey function returns
N tuples, then N keys will be added to the index.

Expand All @@ -665,7 +667,7 @@ N tuples, then N keys will be added to the index.
{body = lua_code,
is_deterministic = true,
is_sandboxed = true,
opts = {is_multikey = true}})
is_multikey = true})
idx = s:create_index('addr', {unique = false,
func = 'address',
parts = {{field = 1, type = 'string',
Expand Down

0 comments on commit 6d13441

Please sign in to comment.