Skip to content

BUG: A SEARCH_INDEX(...) query string containing two or more . characters fails with CommandSQLParsingException: Nested property access is not supported (breaks fractional caret boosts, node.js-style terms, version numbers, ...) #4734

Closed

Description

@TheRealMcoy

Description

SEARCH_INDEX('Index[field]', '<query>') fails to execute when <query> contains two or more . (dot) characters:

CommandSQLParsingException: Nested property access is not supported in this
context: search_index:doc[title]:node.js 3.5

A query with one dot works; two or more dots anywhere in the query string throw. The dots do not have to be related to each other or to boosts - the trigger is purely the count of . in the whole query string. Examples that fail: node.js react.js, version 3.5.1, a.b c.d, and two fractional caret boosts title:java^3.0 title:database^2.0. A single fractional caret (title:java^3.0) and a single dotted term (node.js) both work, which is why this can look caret-specific at first.

This matters because dotted tokens are common in real full-text corpora (node.js, asp.net, file names, package names, version strings, IP/host fragments), and Lucene/Elasticsearch accept fractional caret boosts (term^1.5), so users naturally write queries that hit this.

Environment

  • ArcadeDB Server 26.7.1-SNAPSHOT (build 661e52fce3b84f452f02cc131b9c5608674deb67/1782276736394/main)
  • Default database options
  • Reproduces regardless of similarity (BM25 default or CLASSIC) - it is in the
    SEARCH_INDEX function plumbing, not the scorer

Root cause

SQLFunctionSearchIndex caches its per-query result map under a context variable whose name embeds the raw query string:

engine/src/main/java/com/arcadedb/function/sql/text/SQLFunctionSearchIndex.java:87 (and :180)

final String cacheKey = "search_index:" + indexName + ":" + queryString;
...
Map<RID, Float> allResults = (Map<RID, Float>) iContext.getVariable(cacheKey); // :92 / :182
...
iContext.setVariable(cacheKey, allResults);                                    // :99 / :186

BasicCommandContext.getVariable(String) treats . in a variable name as nested property access ($var.field) and rejects more than one dot:

engine/src/main/java/com/arcadedb/query/sql/executor/BasicCommandContext.java:143

if (name.contains(".")) {
  final String[] parts = name.split("\\.");
  if (parts.length > 2)
    throw new CommandSQLParsingException(
        "Nested property access is not supported in this context: " + name);
  name = parts[0];
  if (parts.length > 1)
    fieldName = parts[1];
}

So the cache key search_index:doc[title]:node.js 3.5 (two dots -> parts.length == 3) trips the guard. With exactly one dot the guard does not throw, but it still silently splits the key into name/fieldName, so the cache lookup is keyed wrong (a latent correctness issue, masked today because the subsequent setVariable/getVariable use the same broken split symmetrically).

The query string is data and should never be interpreted as a variable path.

Steps to reproduce

curl -sS -u root:playwithdata http://localhost:2480/api/v1/command/test \
  -H 'Content-Type: application/json' \
  -d '{"language":"sql","command":"CREATE DOCUMENT TYPE doc"}'
curl -sS -u root:playwithdata http://localhost:2480/api/v1/command/test \
  -H 'Content-Type: application/json' \
  -d '{"language":"sql","command":"CREATE PROPERTY doc.title STRING"}'
curl -sS -u root:playwithdata http://localhost:2480/api/v1/command/test \
  -H 'Content-Type: application/json' \
  -d '{"language":"sql","command":"CREATE INDEX ON doc (title) FULL_TEXT"}'
curl -sS -u root:playwithdata http://localhost:2480/api/v1/command/test \
  -H 'Content-Type: application/json' \
  -d '{"language":"sql","command":"INSERT INTO doc SET title = '"'"'java database node.js version 3.5'"'"'"}'

# ONE dot - OK
curl -sS -u root:playwithdata http://localhost:2480/api/v1/query/test \
  -H 'Content-Type: application/json' \
  -d '{"language":"sql","command":"SELECT title FROM doc WHERE SEARCH_INDEX('"'"'doc[title]'"'"', '"'"'node.js'"'"') = true"}'
#   -> matches
curl -sS -u root:playwithdata http://localhost:2480/api/v1/query/test \
  -H 'Content-Type: application/json' \
  -d '{"language":"sql","command":"SELECT title FROM doc WHERE SEARCH_INDEX('"'"'doc[title]'"'"', '"'"'title:java^3.0'"'"') = true"}'
#   -> matches (single fractional caret = one dot)

# TWO dots - parse error
curl -sS -u root:playwithdata http://localhost:2480/api/v1/query/test \
  -H 'Content-Type: application/json' \
  -d '{"language":"sql","command":"SELECT title FROM doc WHERE SEARCH_INDEX('"'"'doc[title]'"'"', '"'"'node.js 3.5'"'"') = true"}'
#   -> CommandSQLParsingException: Nested property access is not supported in this context:
#        search_index:doc[title]:node.js 3.5
curl -sS -u root:playwithdata http://localhost:2480/api/v1/query/test \
  -H 'Content-Type: application/json' \
  -d '{"language":"sql","command":"SELECT title FROM doc WHERE SEARCH_INDEX('"'"'doc[title]'"'"', '"'"'title:java^3.0 title:database^2.0'"'"') = true"}'
#   -> CommandSQLParsingException: Nested property access is not supported in this context:
#        search_index:doc[title]:title:java^3.0 title:database^2.0

# integer carets (no dots) - OK
curl -sS -u root:playwithdata http://localhost:2480/api/v1/query/test \
  -H 'Content-Type: application/json' \
  -d '{"language":"sql","command":"SELECT title FROM doc WHERE SEARCH_INDEX('"'"'doc[title]'"'"', '"'"'title:java^3 title:database^2'"'"') = true"}'
#   -> matches

Observed

  • SEARCH_INDEX(..., 'node.js 3.5') and SEARCH_INDEX(..., 'title:java^3.0 title:database^2.0') (two dots) throw CommandSQLParsingException: Nested property access is not supported in this context: search_index:<index>:<query>.
  • Single-dot queries (node.js, title:java^3.0) and dot-free queries (title:java^3 title:database^2) succeed.

Expected

The SEARCH_INDEX query string is opaque text handed to the full-text/Lucene query parser. Its content (dots included) must not be parsed as SQL variable/property paths. node.js react.js, version 3.5.1, and fractional caret boosts (title:java^1.5 body:db^0.5) should all execute.

Suggested fix

The result cache should not live in the dotted getVariable/setVariable namespace keyed by the raw query. Options, high level:

  1. Use an opaque cache keyed by the raw string. Store the per-query result map in a dedicated Map<String, Object> on the command context (or a putCachedValue/getCachedValue API) that treats the key as opaque and never applies the .-splitting that getVariable does. Cleanest fix; the cache is an internal concern and has no business in the user-facing variable namespace.
  2. Encode the key. Build the cache key from a hash of indexName + queryString (or escape .), guaranteeing it contains no .. Smaller change, but still abuses the variable namespace.
  3. Scope the getVariable dot-splitting. Only interpret . as nested access for names that did not come from internal caching. More invasive and risks the latent single-dot mis-keying noted above.

Activity

  1. added this to the 26.7.1 milestone on Jun 24, 2026
  2. self-assigned this
    on Jun 24, 2026
  3. added theissue type on Jun 24, 2026
  4. lvca commented on Jun 24, 2026

    @lvca
    Member

    Reproduced

  5. added a commit that references this issue on Jun 24, 2026
  6. lvca commented on Jun 24, 2026

    @lvca
    Member

    Fixed

  7. added a commit that references this issue on Aug 14, 2026
  8. added a commit that references this issue on Oct 15, 2026
  9. added a commit that references this issue on Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions