From 6d13441d81b5829a8d0d19db3af19a04f2c959a4 Mon Sep 17 00:00:00 2001 From: Evgeniy Osintsev Date: Thu, 3 Mar 2022 12:05:00 +0400 Subject: [PATCH] Correct syntax and example for setting is_multikey option for functions Part of #2507 --- doc/reference/reference_lua/box_schema/func_create.rst | 4 ++++ doc/reference/reference_lua/box_space/create_index.rst | 8 +++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/doc/reference/reference_lua/box_schema/func_create.rst b/doc/reference/reference_lua/box_schema/func_create.rst index 6bb8193fc1..1e3e0d6ada 100644 --- a/doc/reference/reference_lua/box_schema/func_create.rst +++ b/doc/reference/reference_lua/box_schema/func_create.rst @@ -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 `. + * ``body`` = function definition (default = nil) - string; the function definition. diff --git a/doc/reference/reference_lua/box_space/create_index.rst b/doc/reference/reference_lua/box_space/create_index.rst index eb3f9cbe72..d9ab0894a3 100644 --- a/doc/reference/reference_lua/box_space/create_index.rst +++ b/doc/reference/reference_lua/box_space/create_index.rst @@ -9,7 +9,7 @@ On this page: * :ref:`Allowing null for an indexed key ` * :ref:`Creating an index using field names instead of field numbers ` * :ref:`Creating an index using the path option for map fields (JSON-path indexes) ` -* :ref:`Creating an multikey index using the path option with [*] ` +* :ref:`Creating a multikey index using the path option with [*] ` * :ref:`Creating a functional index ` .. class:: space_object @@ -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. @@ -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',