Skip to content

SQL: Full-Text Index / CONTAINSTEXT problem with compound filters #3483

@gramian

Description

@gramian

ArcadeDB Server v26.2.1 (build ced6531188602179fef91d7f831373e7ff47284c/1771258648678/UNKNOWN)

Running on Linux 6.17.0-14-generic - OpenJDK 64-Bit Server VM 21.0.10

As a disclaimer to understand this problem one needs to be aware that the CONTAINSTEXT operator works in two different modes:

  1. If applied to a un-indexed property or literal it acts just like a simple contains method
  2. If applied to a full-text indexed property it acts case in-sensitive and performs an OR-combined search given on the right-hand side either an array of strings or string which is split by spaces

Now, a compound filter with multiple CONTAINSTEXT sub-filters causes the sub-filters to act like on an un-indexed property, even though EXPLAIN reports that each sub-filter acts on an index fetch.

Example:

Given:

CREATE DOCUMENT TYPE doc;
CREATE PROPERTY doc.txt STRING;
CREATE INDEX ON doc(txt) FULL_TEXT;
INSERT INTO doc SET txt = 'This is a test'

it is working for a single filter:

SELECT FROM doc WHERE (txt CONTAINSTEXT 'is') -- 1 result
SELECT FROM doc WHERE (txt CONTAINSTEXT 'a is') -- 1 result
SELECT FROM doc WHERE (txt CONTAINSTEXT 'IS') -- 1 result

but for multiple filters (here the same ones, combined with an OR) it fails:

SELECT FROM doc WHERE (txt CONTAINSTEXT 'is') OR (txt CONTAINSTEXT 'is') -- 1 result
SELECT FROM doc WHERE (txt CONTAINSTEXT 'a is') OR (txt CONTAINSTEXT 'a is') -- 0 results
SELECT FROM doc WHERE (txt CONTAINSTEXT 'IS') OR (txt CONTAINSTEXT 'IS') -- 0 result

since no results are returned for non-exact search words.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions