From 630e93e35d89d5fc2c0555e629d14adab76f0980 Mon Sep 17 00:00:00 2001 From: Taewoon Kim Date: Fri, 27 Nov 2026 17:55:42 +0900 Subject: [PATCH 1/2] docs(#505): the four faceted-query limits and the vector dimension cap of 26.12.1 Each value was read from the engine source at 8851991e1 (GlobalConfiguration and the code that enforces each limit). The limits came into 26.12.1 after the first snapshots, so the blocks that state them run only on an engine that has the setting; a release without it fails the test. --- .../ROOT/pages/how-to/columnar-index.adoc | 5 +- docs/modules/ROOT/pages/how-to/facets.adoc | 92 +++++++++++++++++++ docs/modules/ROOT/pages/how-to/vectors.adoc | 57 ++++++++++++ docs/modules/ROOT/pages/upgrading.adoc | 1 + tests/test_columnar_index.py | 36 ++++++++ tests/test_docs_facets_page.py | 87 ++++++++++++++++-- tests/test_docs_vectors_page.py | 42 ++++++++- 7 files changed, 307 insertions(+), 13 deletions(-) diff --git a/docs/modules/ROOT/pages/how-to/columnar-index.adoc b/docs/modules/ROOT/pages/how-to/columnar-index.adoc index 2ba2d933..b4c7e64b 100644 --- a/docs/modules/ROOT/pages/how-to/columnar-index.adoc +++ b/docs/modules/ROOT/pages/how-to/columnar-index.adoc @@ -33,8 +33,9 @@ The projection survives a close. After a clean close, and after a process that e The engine reads the settings of the projection from `arcadedb.columnar.*`. Which route sets one depends on its scope in `GlobalConfiguration`, and there is no setter of its own in Python: the routes that exist already are enough. -* Scope database (`flushInterval`, `flushMaxRows`, `flushMinRows`, `flushMaxAge`, `mergeDeadRatio`, `mergeMaxSegments`, `maxCardinality`, `segmentBlockRows`, `applyInterval`, `applyMaxLag`, `dictionaryCompactRatio`, `maxFallbackScans` and `groupByAcceleration`): `ALTER DATABASE`. It takes effect at once, is stored with the database and is still there after a reopen. `SELECT settings FROM schema:database` lists the value and the default of each. -* Scope JVM (`applyThreads`, `maintenanceThreads`, `rebuildConcurrency`, `queryMemoryBudget`) and scope server (`patchBudget`, `patchBudgetRatio`, `queryBudgetWait`, `parallelCountTasks`, `parallelMinMatches`, `topMax`): `ALTER DATABASE` refuses them with `cannot be set per database`. Set them as system properties before the engine starts, as for `arcadedb.fileSync` on xref:how-to/durability.adoc[Durability settings]: `-Darcadedb.columnar.applyThreads=4` in `jvm_kwargs={"jvm_args": [...]}` or in `ARCADEDB_JVM_ARGS` for `arcadedb-jvm`, and in `ARCADEDB_NATIVE_ISOLATE_ARGS` for `arcadedb`. The pool settings are read once, when the pool starts. No test here sets a system property. +* Scope database (`flushInterval`, `flushMaxRows`, `flushMinRows`, `flushMaxAge`, `mergeDeadRatio`, `mergeMaxSegments`, `maxCardinality`, `segmentBlockRows`, `applyInterval`, `applyMaxLag`, `dictionaryCompactRatio`, `maxFallbackScans`, `groupByAcceleration`, `hierarchyMaxNodes` and `hierarchyMaxDepth`): `ALTER DATABASE`. It takes effect at once, is stored with the database and is still there after a reopen. `SELECT settings FROM schema:database` lists the value and the default of each. +* Scope JVM (`applyThreads`, `maintenanceThreads`, `rebuildConcurrency`, `queryMemoryBudget`) and scope server (`patchBudget`, `patchBudgetRatio`, `queryBudgetWait`, `parallelCountTasks`, `parallelMinMatches`, `topMax`, `maxFacetsPerQuery`, `maxResponseBuckets`): `ALTER DATABASE` refuses them with `cannot be set per database`. Set them as system properties before the engine starts, as for `arcadedb.fileSync` on xref:how-to/durability.adoc[Durability settings]: `-Darcadedb.columnar.applyThreads=4` in `jvm_kwargs={"jvm_args": [...]}` or in `ARCADEDB_JVM_ARGS` for `arcadedb-jvm`, and in `ARCADEDB_NATIVE_ISOLATE_ARGS` for `arcadedb`. The pool settings are read once, when the pool starts. A test here sets one of them this way, `maxResponseBuckets`, in a child process (`tests/test_docs_facets_page.py`). +* `maxFacetsPerQuery`, `maxResponseBuckets`, `hierarchyMaxNodes` and `hierarchyMaxDepth` limit a faceted query. Their defaults and what a query sees at a limit are on xref:how-to/facets.adoc#limits[Faceted queries]. [source,python] ---- diff --git a/docs/modules/ROOT/pages/how-to/facets.adoc b/docs/modules/ROOT/pages/how-to/facets.adoc index bc51a9e8..9d1d2adf 100644 --- a/docs/modules/ROOT/pages/how-to/facets.adoc +++ b/docs/modules/ROOT/pages/how-to/facets.adoc @@ -629,6 +629,98 @@ mid 4 The `[30, 70)` interval holds the scores 30, 40, 50 and 60. The last query shows that the filter of the `STATS` facet narrows the rows, and the `DISTINCT` facet counts the 4 categories of the records that pass. +[[limits]] +== Limits of one query + +Four settings limit a faceted query. The engine added them on 2026-11-07, so a pre-release of 26.12.1 built before that day does not have them. Where each one is set is on xref:how-to/columnar-index.adoc[The COLUMNAR index and its settings]. + +[cols="3,1,1,4"] +|=== +| Setting | Scope | Default | At the limit + +| `arcadedb.columnar.maxFacetsPerQuery` +| server +| 32 +| A `FACETS` clause with more facets is a parse error. + +| `arcadedb.columnar.maxResponseBuckets` +| server +| 250,000 +| The facets of one query return at most this many buckets together. They are taken in the order of the clause: a facet that does not fit is `unavailable` with the reason `bucket limit`, and a later one that fits is answered. + +| `arcadedb.columnar.hierarchyMaxNodes` +| database +| 0 (no limit) +| A `HIERARCHY` facet over a tree with more nodes (distinct tags) is `unavailable`. + +| `arcadedb.columnar.hierarchyMaxDepth` +| database +| 0 (no limit) +| A `HIERARCHY` facet over a tree that is deeper, counted in links from a root, is `unavailable`. +|=== + +One facet more than the default allows is refused when the statement is parsed, and 32 facets are answered: + +.Needs engine 26.12.1 or later +[source,python,role=needs-engine-limits] +---- +from arcadedb import QuerySyntaxError + + +def facet_clause(n): + return ", ".join(f"f{i}: category TERMS TOP 1" for i in range(n)) + + +try: + db.query("sql", f"SELECT id FROM FacetDoc FACETS {facet_clause(33)}").to_list() +except QuerySyntaxError as e: + print(e.code, "arcadedb.columnar.maxFacetsPerQuery" in str(e)) + +rs = db.query("sql", f"SELECT id FROM FacetDoc FACETS {facet_clause(32)}") +rs.to_list() +print(len(rs.facets) - 1) # every key but meta is a facet +---- + +[source,text] +---- +syntax_error True +32 +---- + +The two hierarchy limits have database scope, and the engine reads them when it builds the hierarchy of an index. The block sets one, creates an index over the `Tag` tree of above (4 vertices, 2 links deep), and sets the limit back to 0: + +.Needs engine 26.12.1 or later +[source,python,role=needs-engine-limits] +---- +metadata = '{"hierarchy": {"vertexType": "Tag", "key": "path", "parentEdge": "ParentOf"}}' + +for name, setting, limit in ( + ("Narrow", "hierarchyMaxNodes", 3), + ("Flat", "hierarchyMaxDepth", 1), +): + db.command("sql", f"ALTER DATABASE `arcadedb.columnar.{setting}` {limit}") + db.command("sql", f"CREATE DOCUMENT TYPE {name}") + db.command("sql", f"CREATE PROPERTY {name}.tags LIST OF STRING") + db.command("sql", f"CREATE INDEX ON {name} (tags BY ITEM) COLUMNAR METADATA {metadata}") + db.command("sql", f"INSERT INTO {name} SET tags = ['t0/a/x']") + rs = db.query("sql", f"SELECT FROM {name} FACETS t: tags HIERARCHY TOP 100") + rs.to_list() + facet = rs.facets["t"] + print(facet["source"]) + print(facet["reason"]) + db.command("sql", f"ALTER DATABASE `arcadedb.columnar.{setting}` 0") +---- + +[source,text] +---- +unavailable +hierarchy of Tag.path has more than 3 nodes (arcadedb.columnar.hierarchyMaxNodes) +unavailable +hierarchy of Tag.path has deeper than 1 levels (arcadedb.columnar.hierarchyMaxDepth) +---- + +The bucket limit has server scope, so it cannot change while a program runs. The test of this page checks it in a child process that starts the engine with a limit of 3. + [[older-engine]] == An older engine diff --git a/docs/modules/ROOT/pages/how-to/vectors.adoc b/docs/modules/ROOT/pages/how-to/vectors.adoc index 1d29d0d8..8ad7ad57 100644 --- a/docs/modules/ROOT/pages/how-to/vectors.adoc +++ b/docs/modules/ROOT/pages/how-to/vectors.adoc @@ -66,6 +66,63 @@ NONE True Name the setting in the statement or in the call when you compare results or need the same index from both paths. `"quantization": "INT8"` and `"addHierarchy": true` in the `METADATA` give the method's index; `quantization=None` in the call gives the statement's (and `add_hierarchy=False` on 26.11.1 and earlier, where the statement builds a flat graph). Do not take `INT8` as the best choice from its being the method's default: check recall and speed on your own data. +[[dimension-limit]] +=== The dimension limit + +From engine 26.12.1, a new `LSM_VECTOR` index can have at most 16,384 dimensions. The engine added the limit on 2026-11-21, so a pre-release of 26.12.1 built before that day does not have it. A wider index is refused with `ArcadeDBError`, and an index that takes its dimensions from its first vector (`sizeOnFirstVector`) refuses that vector. To raise the limit, set `arcadedb.vectorIndex.maxDimensions` for the database before you create the index. An index that is already stored keeps working when the limit is below its size. + +.Needs engine 26.12.1 or later +[source,python,role=needs-engine-limits] +---- +from arcadedb import ArcadeDBError + +setting = "arcadedb.vectorIndex.maxDimensions" +create = ( + "CREATE INDEX ON Wide (v) LSM_VECTOR " + 'METADATA {"dimensions": 16385, "similarity": "COSINE"}' +) +db.command("sql", "CREATE DOCUMENT TYPE Wide") +db.command("sql", "CREATE PROPERTY Wide.v ARRAY_OF_FLOATS") +for attempt in ( + lambda: db.command("sql", create), + lambda: db.create_vector_index("Wide", "v", dimensions=16385), +): + try: + attempt() + except ArcadeDBError as e: + print("refused:", setting in str(e)) + +db.command("sql", f"ALTER DATABASE `{setting}` 20000") +db.command("sql", create) +wide = db.schema.get_vector_index("Wide", "v") +print(wide.get_metadata()["dimensions"]) + +db.command("sql", f"ALTER DATABASE `{setting}` 16384") # the index stays +vector = np.ones(16385, dtype=np.float32) +db.command("sql", "INSERT INTO Wide SET v = ?", vector) +print(len(wide.find_nearest(vector, k=1))) + +db.command("sql", "CREATE DOCUMENT TYPE Later") +db.command("sql", "CREATE PROPERTY Later.v ARRAY_OF_FLOATS") +db.command("sql", 'CREATE INDEX ON Later (v) LSM_VECTOR METADATA {"sizeOnFirstVector": true}') +try: + db.command("sql", "INSERT INTO Later SET v = ?", vector) +except ArcadeDBError as e: + print("refused:", setting in str(e)) + +db.command("sql", "DROP TYPE Wide UNSAFE") +db.command("sql", "DROP TYPE Later UNSAFE") +---- + +[source,text] +---- +refused: True +refused: True +16385 +1 +refused: True +---- + == Insert vectors A vector is a property value like any other. Bind it as a parameter of `INSERT`. A NumPy `float32` array crosses into the engine as one buffer. A list of Python floats also works, and a list that is the only parameter of a statement is read as the whole parameter list, so give a vector as a list only next to other parameters or by name. The details are in xref:how-to/databases-and-queries.adoc#a-query-vector[A query vector]. diff --git a/docs/modules/ROOT/pages/upgrading.adoc b/docs/modules/ROOT/pages/upgrading.adoc index 2a77bfa3..4881cdaa 100644 --- a/docs/modules/ROOT/pages/upgrading.adoc +++ b/docs/modules/ROOT/pages/upgrading.adoc @@ -50,6 +50,7 @@ Before, `{native-pkg-name}` stored every whole number that `insert_many` wrote a The engine that the 26.12.1 packages carry changes some behaviour that the other pages describe: * A vector index that `CREATE INDEX ... LSM_VECTOR` makes without `addHierarchy` has the HNSW hierarchy layers; on 26.11.1 and earlier it was a flat graph. `create_vector_index` already asked for the layers. See xref:how-to/vectors.adoc[Vectors]. +* A new `LSM_VECTOR` index with more than 16,384 dimensions is refused, and so is the first vector of that length in an index that takes its dimensions from it. To create a wider index, first run `+ALTER DATABASE `arcadedb.vectorIndex.maxDimensions` 20000+`, with the number that your vectors need. An index that is already stored keeps working. See xref:how-to/vectors.adoc#dimension-limit[The dimension limit]. * `EXPORT DATABASE` refuses a setting that it does not know and some values that it accepted before: see xref:how-to/import-export.adoc[Importing and exporting data]. Keep a backup of the database directory before you upgrade. With the engine change https://github.com/ArcadeData/arcadedb/pull/12239[ArcadeData/arcadedb#12239], a read-write open labels the database, and 26.11.1 then refuses to open it. The way to prevent the label is on xref:installation.adoc#older-wheel[Open a database with an older wheel]. diff --git a/tests/test_columnar_index.py b/tests/test_columnar_index.py index 8f1153cd..86c5be60 100644 --- a/tests/test_columnar_index.py +++ b/tests/test_columnar_index.py @@ -96,6 +96,15 @@ "arcadedb.columnar.parallelMinMatches", "arcadedb.columnar.topMax", ] +# the limits that came into 26.12.1 after its first snapshots (ArcadeData/arcadedb#11395 and #11399), with their defaults +LIMIT_DATABASE_SETTINGS = { + "arcadedb.columnar.hierarchyMaxNodes": "0", + "arcadedb.columnar.hierarchyMaxDepth": "0", +} +LIMIT_SERVER_SETTINGS = { + "arcadedb.columnar.maxFacetsPerQuery": "32", + "arcadedb.columnar.maxResponseBuckets": "250000", +} @pytest.fixture @@ -541,6 +550,33 @@ def test_database_settings_are_listed_with_their_defaults(self, test_db): assert _text(settings[GROUP_BY_KEY]["default"]) == "true" assert _text(settings[GROUP_BY_KEY]["value"]) == "true" + def test_the_limits_of_a_faceted_query_have_the_documented_scopes_and_defaults( + self, test_db + ): + settings = _settings(test_db) + version = str( + test_db.query("sql", "SELECT version() AS v").first().get("v") + ).split()[0] + if "arcadedb.columnar.hierarchyMaxNodes" not in settings: + # an engine before 26.12.1, or a snapshot of it from before the limits + assert ( + _engine_version(test_db) < FACETS_SINCE or "SNAPSHOT" in version + ), version + with pytest.raises(Exception, match="not found"): + _alter(test_db, "arcadedb.columnar.hierarchyMaxNodes", 3) + return + + for key, default in LIMIT_DATABASE_SETTINGS.items(): + assert _text(settings[key]["default"]) == default, key + _alter(test_db, key, 7) + assert _text(_settings(test_db)[key]["value"]) == "7", key + for key, default in LIMIT_SERVER_SETTINGS.items(): + assert key not in settings, key + with pytest.raises(Exception) as refused: + _alter(test_db, key, default) + assert "SERVER scope" in str(refused.value), key + assert "cannot be set per database" in str(refused.value), key + def test_settings_of_the_jvm_and_of_a_server_are_not_database_settings( self, test_db ): diff --git a/tests/test_docs_facets_page.py b/tests/test_docs_facets_page.py index fa07d2c3..b285c2a3 100644 --- a/tests/test_docs_facets_page.py +++ b/tests/test_docs_facets_page.py @@ -12,11 +12,20 @@ is what the page documents, and the test asserts that refusal instead of the output. Nothing is skipped (the repository accepts no skips, scripts/check_test_skips.py). The version is read through the test's database (``SELECT version()``), so the same check runs on both builds. + +The limits of a faceted query came into 26.12.1 after its first snapshots, so a block that states one carries +``role=needs-engine-limits``. It runs on an engine that has the settings (``arcadedb.columnar.hierarchyMaxNodes`` is listed by +``SELECT settings FROM schema:database``, which a 26.12.1 release must have). On any other engine the test asserts that the engine +does not know the setting. """ import contextlib import io +import json +import os import re +import subprocess # nosec B404 - runs this interpreter on a script of this file +import sys from pathlib import Path import pytest @@ -49,14 +58,15 @@ def _blocks(): - """The Python blocks as (code, expected output or None, needs the new engine).""" + """The Python blocks as (code, expected output or None, needs the new engine, needs the limits).""" text = PAGE.read_text(encoding="utf-8") found = [] for m in BLOCK_RE.finditer(text): needs = "role=needs-engine" in m.group("attrs") # the title and the role say the same thing, in both directions assert needs == (m.group("title") == NEEDS_TITLE), m.group("code")[:80] - found.append((m.group("code"), m.group("out"), needs)) + needs_limits = "role=needs-engine-limits" in m.group("attrs") + found.append((m.group("code"), m.group("out"), needs, needs_limits)) # no Python listing may escape the extraction (a different spelling of the block header would run nowhere) assert text.count("[source,python") == len(found) return found @@ -72,17 +82,31 @@ def _engine_version(db): return tuple(parts + [0] * (3 - len(parts))) +LIMIT_PROBE = "arcadedb.columnar.hierarchyMaxNodes" + + +def _has_limits(db): + """Whether the engine has the limits of a faceted query. A 26.12.1 snapshot may lack them; a release may not.""" + row = db.query("sql", "SELECT settings FROM schema:database").first() + present = LIMIT_PROBE in {s["key"] for s in row.get("settings")} + version = str(db.query("sql", "SELECT version() AS v").first().get("v")).split()[0] + if _engine_version(db) >= FACETS_SINCE and "SNAPSHOT" not in version: + assert present, version + return present + + def test_the_page_has_its_blocks(): blocks = _blocks() assert len(blocks) >= 18 - assert sum(1 for _, out, _ in blocks if out is not None) >= 14 - needing = [code for code, _, needs in blocks if needs] + assert sum(1 for _, out, _, _ in blocks if out is not None) >= 14 + assert sum(1 for *_, needs_limits in blocks if needs_limits) == 2 + needing = [code for code, _, needs, _ in blocks if needs] assert len(needing) >= 12 # every block that needs the new engine says so: its first engine call is a COLUMNAR index or a FACETS query for code in needing: assert "COLUMNAR" in code or "FACETS" in code, code[:80] # and no other block does: they all run on an engine without facets - for code, _, needs in blocks: + for code, _, needs, _ in blocks: if not needs: assert "FACETS" not in code and "COLUMNAR" not in code, code[:80] @@ -90,10 +114,16 @@ def test_the_page_has_its_blocks(): def test_every_block_runs_in_order_and_prints_what_the_page_says(temp_db): namespace = {"db": temp_db, "__name__": "facets_page"} newer = _engine_version(temp_db) >= FACETS_SINCE + limits = _has_limits(temp_db) + if not limits: + with pytest.raises(Exception, match="not found"): + temp_db.command("sql", f"ALTER DATABASE `{LIMIT_PROBE}` 3") refused = 0 - for number, (code, expected, needs) in enumerate(_blocks(), start=1): + for number, (code, expected, needs, needs_limits) in enumerate(_blocks(), start=1): compiled = compile(code, f"facets.adoc python block {number}", "exec") captured = io.StringIO() + if needs_limits and not limits: + continue if needs and not newer: # an older engine: the block is refused with the engine's own error, before it prints anything with pytest.raises(Exception, match=REFUSAL): @@ -118,3 +148,48 @@ def test_every_block_runs_in_order_and_prints_what_the_page_says(temp_db): # the page's own version check agrees with the test's, on the engine of this lane assert namespace["has_facets"] is newer assert (refused == 0) == newer + + +# four buckets for `a` and two for `b`: with a limit of 3 the first facet does not fit and the second does +BUCKET_SCRIPT = """ +import json, sys +import arcadedb + +with arcadedb.create_database(sys.argv[1]) as db: + db.command("sql", "CREATE DOCUMENT TYPE D") + db.command("sql", "CREATE PROPERTY D.a STRING") + db.command("sql", "CREATE PROPERTY D.b STRING") + db.command("sql", "CREATE INDEX ON D (a) COLUMNAR") + db.command("sql", "CREATE INDEX ON D (b) COLUMNAR") + with db.transaction(): + for i in range(8): + db.command("sql", "INSERT INTO D SET a = ?, b = ?", f"a{i % 4}", f"b{i % 2}") + rs = db.query("sql", "SELECT FROM D FACETS wide: a TERMS TOP 10, narrow: b TERMS TOP 10") + rs.to_list() + facets = rs.facets + print(json.dumps({k: [facets[k]["source"], facets[k].get("reason")] for k in ("wide", "narrow")})) +""" + + +def test_a_facet_above_the_bucket_limit_is_unavailable(temp_db, tmp_path): + """`arcadedb.columnar.maxResponseBuckets` has server scope, so it is set before the engine of a child process starts.""" + if not _has_limits(temp_db): + with pytest.raises(Exception, match="not found"): + temp_db.command("sql", f"ALTER DATABASE `{LIMIT_PROBE}` 3") + return + option = "-Darcadedb.columnar.maxResponseBuckets=3" + env = dict(os.environ) + for name in ("ARCADEDB_JVM_ARGS", "ARCADEDB_NATIVE_ISOLATE_ARGS"): + env[name] = f"{env.get(name, '')} {option}".strip() + result = subprocess.run( # nosec B603 - this interpreter and the script above + [sys.executable, "-c", BUCKET_SCRIPT, str(tmp_path / "bucket_limit_db")], + env=env, + cwd=tmp_path, + capture_output=True, + text=True, + timeout=300, + ) + assert result.returncode == 0, result.stderr + answer = json.loads(result.stdout.strip().splitlines()[-1]) + assert answer["wide"] == ["unavailable", "bucket limit"] + assert answer["narrow"][0] in ("index", "scan") diff --git a/tests/test_docs_vectors_page.py b/tests/test_docs_vectors_page.py index adf72ecd..0ce342e8 100644 --- a/tests/test_docs_vectors_page.py +++ b/tests/test_docs_vectors_page.py @@ -4,6 +4,9 @@ temporary database that the namespace holds as ``db`` (the page says that each block assumes an open ``db``). A block that is followed by a ``[source,text]`` block must print exactly that text. The test uses no Java object, so it runs on the JVM build and the native build alike. + +A block with ``role=needs-engine-limits`` states the dimension limit, which came into 26.12.1 after its first snapshots. It runs on +an engine that has ``arcadedb.vectorIndex.maxDimensions``; on any other engine the test asserts that the engine does not know it. """ import contextlib @@ -11,6 +14,8 @@ import re from pathlib import Path +import pytest + PAGE = ( Path(__file__).resolve().parents[1] / "docs" @@ -23,7 +28,7 @@ # a Python listing, then (optionally, directly after it) the text listing with its output BLOCK_RE = re.compile( - r"\[source,python[^\]\n]*\]\n----\n(?P.*?)\n----\n" + r"\[source,python(?P[^\]\n]*)\]\n----\n(?P.*?)\n----\n" r"(?:\n\[source,text\]\n----\n(?P.*?)\n----\n)?", re.DOTALL, ) @@ -31,7 +36,14 @@ def _blocks(): text = PAGE.read_text(encoding="utf-8") - found = [(m.group("code"), m.group("out")) for m in BLOCK_RE.finditer(text)] + found = [ + ( + m.group("code"), + m.group("out"), + "role=needs-engine-limits" in m.group("attrs"), + ) + for m in BLOCK_RE.finditer(text) + ] # no Python listing may escape the extraction (a different spelling of the block header would run nowhere) assert text.count("[source,python") == len(found) return found @@ -54,16 +66,36 @@ def _engine_version(db): return tuple(parts + [0] * (3 - len(parts))) +LIMIT_SETTING = "arcadedb.vectorIndex.maxDimensions" + + +def _has_dimension_limit(db): + """Whether the engine has the dimension limit. A 26.12.1 snapshot may lack it; a release may not.""" + row = db.query("sql", "SELECT settings FROM schema:database").first() + present = LIMIT_SETTING in {s["key"] for s in row.get("settings")} + version = str(db.query("sql", "SELECT version() AS v").first().get("v")).split()[0] + if _engine_version(db) >= (26, 12, 1) and "SNAPSHOT" not in version: + assert present, version + return present + + def test_the_page_has_its_blocks(): blocks = _blocks() - assert len(blocks) >= 10 - assert sum(1 for _, out in blocks if out is not None) >= 8 + assert len(blocks) >= 11 + assert sum(1 for _, out, _ in blocks if out is not None) >= 9 + assert sum(1 for *_, needs_limit in blocks if needs_limit) == 1 def test_every_block_runs_in_order_and_prints_what_the_page_says(temp_db): namespace = {"db": temp_db, "__name__": "vectors_page"} newer = _engine_version(temp_db) >= HIERARCHY_SINCE - for number, (code, expected) in enumerate(_blocks(), start=1): + has_limit = _has_dimension_limit(temp_db) + if not has_limit: + with pytest.raises(Exception, match="not found"): + temp_db.command("sql", f"ALTER DATABASE `{LIMIT_SETTING}` 20000") + for number, (code, expected, needs_limit) in enumerate(_blocks(), start=1): + if needs_limit and not has_limit: + continue captured = io.StringIO() compiled = compile(code, f"vectors.adoc python block {number}", "exec") with contextlib.redirect_stdout(captured): From 5b09936fcea641e8e1e12a4466c6df7b455cccbe Mon Sep 17 00:00:00 2001 From: Taewoon Kim Date: Fri, 27 Nov 2026 18:06:17 +0900 Subject: [PATCH 2/2] docs(#505): the index that sizes itself on its first vector comes from openCypher The SQL statement refuses a METADATA clause without dimensions, so the block that CI ran failed there. --- docs/modules/ROOT/pages/how-to/vectors.adoc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/docs/modules/ROOT/pages/how-to/vectors.adoc b/docs/modules/ROOT/pages/how-to/vectors.adoc index 8ad7ad57..c1f1972c 100644 --- a/docs/modules/ROOT/pages/how-to/vectors.adoc +++ b/docs/modules/ROOT/pages/how-to/vectors.adoc @@ -69,7 +69,7 @@ Name the setting in the statement or in the call when you compare results or nee [[dimension-limit]] === The dimension limit -From engine 26.12.1, a new `LSM_VECTOR` index can have at most 16,384 dimensions. The engine added the limit on 2026-11-21, so a pre-release of 26.12.1 built before that day does not have it. A wider index is refused with `ArcadeDBError`, and an index that takes its dimensions from its first vector (`sizeOnFirstVector`) refuses that vector. To raise the limit, set `arcadedb.vectorIndex.maxDimensions` for the database before you create the index. An index that is already stored keeps working when the limit is below its size. +From engine 26.12.1, a new `LSM_VECTOR` index can have at most 16,384 dimensions. The engine added the limit on 2026-11-21, so a pre-release of 26.12.1 built before that day does not have it. A wider index is refused with `ArcadeDBError`, and an index that takes its dimensions from its first vector (openCypher `CREATE VECTOR INDEX` without `vector.dimensions`) refuses that vector. To raise the limit, set `arcadedb.vectorIndex.maxDimensions` for the database before you create the index. An index that is already stored keeps working when the limit is below its size. .Needs engine 26.12.1 or later [source,python,role=needs-engine-limits] @@ -102,11 +102,10 @@ vector = np.ones(16385, dtype=np.float32) db.command("sql", "INSERT INTO Wide SET v = ?", vector) print(len(wide.find_nearest(vector, k=1))) -db.command("sql", "CREATE DOCUMENT TYPE Later") -db.command("sql", "CREATE PROPERTY Later.v ARRAY_OF_FLOATS") -db.command("sql", 'CREATE INDEX ON Later (v) LSM_VECTOR METADATA {"sizeOnFirstVector": true}') +# no vector.dimensions: this index takes them from its first vector +db.command("opencypher", "CREATE VECTOR INDEX later_v FOR (n:Later) ON n.v") try: - db.command("sql", "INSERT INTO Later SET v = ?", vector) + db.command("sql", "CREATE VERTEX Later SET v = ?", vector) except ArcadeDBError as e: print("refused:", setting in str(e))