arcadedb 0.5.0 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/CHANGELOG.md +31 -0
- data/Gemfile +0 -1
- data/Gemfile.lock +64 -58
- data/RAG_SCHEMA.md +239 -0
- data/README.md +131 -236
- data/arcade.yml +5 -5
- data/bin/console +1 -0
- data/examples/rag_example.rb +72 -0
- data/examples/rag_usecase_demo.rb +345 -0
- data/lib/arcade/api/operations.rb +33 -24
- data/lib/arcade/api/primitives.rb +52 -2
- data/lib/arcade/base.rb +35 -14
- data/lib/arcade/database.rb +16 -7
- data/lib/arcade/init.rb +5 -2
- data/lib/arcade/match.rb +85 -37
- data/lib/arcade/query.rb +10 -15
- data/lib/arcade/rag_schema.rb +131 -0
- data/lib/arcade/support/model.rb +20 -13
- data/lib/arcade/support/sql.rb +1 -1
- data/lib/arcade/support/string.rb +11 -14
- data/lib/arcade/timeseries.rb +211 -0
- data/lib/arcade/version.rb +1 -1
- data/lib/arcade.rb +7 -4
- data/lib/model/document.rb +1 -1
- data/lib/model/edge.rb +17 -0
- data/lib/model/revision.rb +41 -0
- data/lib/model/revision_record.rb +29 -0
- data/lib/model/timeseries.rb +6 -0
- data/lib/model/vertex.rb +52 -1
- data/lib/models.rb +3 -0
- data/lib/types.rb +35 -0
- metadata +12 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 110182caec09f3fc4bf3ae6cb1980e6ba46f86818aa5d35d2c6f933af0516ea3
|
|
4
|
+
data.tar.gz: af268bcc336188268d48ed65c651ec3fba2c0d67a9de0cfdbe1fc1b6cad3010d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '052078657583b093639c2a8f10764d11d8f1ad331cf128bc1999b420969e86f573a5af8aa3d26b6988969eea287ba64f6f658e8d361f491a5484a1643c26c7eb'
|
|
7
|
+
data.tar.gz: 8b42dadea114563262cdf3e803a48f5d0b0af56e5f033b0dfa3af01bf04994af670bc6acdd1860a3a199b51c7ceabeb8d0d734a88fd72243f8e8bc7ffdb3ea38
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -31,3 +31,34 @@ All notable changes to this project will be documented in this file.
|
|
|
31
31
|
- Arcade::Match simple match-statement generator
|
|
32
32
|
- return to Arcade::QueryError messages instead of HTTPX::HTTPError
|
|
33
33
|
- The ProjectRoot Const is used to read configuration files (Changed from Arcade::ProjectRoot)
|
|
34
|
+
|
|
35
|
+
## 0.5.1 - 2024-1-16
|
|
36
|
+
- Included Arcade::RevisionRecord and Arcade::Revision model classes
|
|
37
|
+
- Both provide basic support for audit proofed bookings
|
|
38
|
+
## 0.5.2 - 2025-02-11
|
|
39
|
+
- Include method Object#descendants (part of active-support)
|
|
40
|
+
- Separate Dry::Type definitions to /lib/types.rb
|
|
41
|
+
- added Vertex#coe (count of edeges) as service method for to_human
|
|
42
|
+
- updated Match#inE, #outE methods to facilitate queries on properties on edges
|
|
43
|
+
## - 2025-03-15
|
|
44
|
+
- support of Match.new vertex: {a prefetched Arcade::Vertex} and match.node( vertex: ...)
|
|
45
|
+
## - 2025-03-25
|
|
46
|
+
- support of Vertex.match( where conditions [, as: :return_element] )
|
|
47
|
+
- added Vertex#match to build 'MATCH type: {class} rid: {rid}'
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
## 0.5.3 - 2026-04-02
|
|
51
|
+
- support for RAG
|
|
52
|
+
- RAG modus is invoked through "rag_db_init" in the model file
|
|
53
|
+
|
|
54
|
+
## 0.5.4 - 2026-10-20
|
|
55
|
+
- Arcade::Timeseries — model class for native time-series types
|
|
56
|
+
- schema DSL: timestamp (precision-aware) / tags / fields → CREATE TIMESERIES TYPE
|
|
57
|
+
- write / write_many via InfluxDB Line Protocol (new Api.post_text)
|
|
58
|
+
- range, bucket (ts.timeBucket + ts.last aggregates), latest (Api.get_json / post_json)
|
|
59
|
+
- create_type waits for asynchronous type registration
|
|
60
|
+
- README rebuilt for machine-readable consumption; server-quirk table added
|
|
61
|
+
(schema:types blind to TS types, DELETE reports but does not delete TS rows on 26.10.1,
|
|
62
|
+
ns timestamp default, reserved word `bucket`)
|
|
63
|
+
- spec/lib/timeseries_spec.rb (5 examples)
|
|
64
|
+
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
arcadedb (0.
|
|
4
|
+
arcadedb (0.5.2)
|
|
5
5
|
dry-configurable
|
|
6
6
|
dry-core
|
|
7
7
|
dry-schema
|
|
@@ -12,47 +12,53 @@ GEM
|
|
|
12
12
|
remote: https://rubygems.org/
|
|
13
13
|
specs:
|
|
14
14
|
awesome_print (1.9.2)
|
|
15
|
+
bigdecimal (4.1.0)
|
|
15
16
|
coderay (1.1.3)
|
|
16
|
-
concurrent-ruby (1.
|
|
17
|
-
diff-lcs (1.
|
|
18
|
-
dry-configurable (1.
|
|
19
|
-
dry-core (~> 1.
|
|
17
|
+
concurrent-ruby (1.3.6)
|
|
18
|
+
diff-lcs (1.6.2)
|
|
19
|
+
dry-configurable (1.3.0)
|
|
20
|
+
dry-core (~> 1.1)
|
|
20
21
|
zeitwerk (~> 2.6)
|
|
21
|
-
dry-core (1.0
|
|
22
|
+
dry-core (1.2.0)
|
|
22
23
|
concurrent-ruby (~> 1.0)
|
|
24
|
+
logger
|
|
23
25
|
zeitwerk (~> 2.6)
|
|
24
|
-
dry-inflector (1.
|
|
25
|
-
dry-initializer (3.
|
|
26
|
-
dry-logic (1.
|
|
26
|
+
dry-inflector (1.3.1)
|
|
27
|
+
dry-initializer (3.2.0)
|
|
28
|
+
dry-logic (1.6.0)
|
|
29
|
+
bigdecimal
|
|
27
30
|
concurrent-ruby (~> 1.0)
|
|
28
|
-
dry-core (~> 1.
|
|
31
|
+
dry-core (~> 1.1)
|
|
29
32
|
zeitwerk (~> 2.6)
|
|
30
|
-
dry-schema (1.
|
|
33
|
+
dry-schema (1.16.0)
|
|
31
34
|
concurrent-ruby (~> 1.0)
|
|
32
35
|
dry-configurable (~> 1.0, >= 1.0.1)
|
|
33
|
-
dry-core (~> 1.
|
|
34
|
-
dry-initializer (~> 3.
|
|
35
|
-
dry-logic (
|
|
36
|
-
dry-types (
|
|
36
|
+
dry-core (~> 1.1)
|
|
37
|
+
dry-initializer (~> 3.2)
|
|
38
|
+
dry-logic (~> 1.6)
|
|
39
|
+
dry-types (~> 1.9, >= 1.9.1)
|
|
37
40
|
zeitwerk (~> 2.6)
|
|
38
|
-
dry-struct (1.
|
|
39
|
-
dry-core (~> 1.
|
|
40
|
-
dry-types (
|
|
41
|
+
dry-struct (1.8.1)
|
|
42
|
+
dry-core (~> 1.1)
|
|
43
|
+
dry-types (~> 1.8, >= 1.8.2)
|
|
41
44
|
ice_nine (~> 0.11)
|
|
42
45
|
zeitwerk (~> 2.6)
|
|
43
|
-
dry-types (1.
|
|
46
|
+
dry-types (1.9.1)
|
|
47
|
+
bigdecimal (>= 3.0)
|
|
44
48
|
concurrent-ruby (~> 1.0)
|
|
45
49
|
dry-core (~> 1.0)
|
|
46
50
|
dry-inflector (~> 1.0)
|
|
47
51
|
dry-logic (~> 1.4)
|
|
48
52
|
zeitwerk (~> 2.6)
|
|
49
|
-
ffi (1.
|
|
50
|
-
formatador (1.
|
|
53
|
+
ffi (1.17.4-x86_64-linux-gnu)
|
|
54
|
+
formatador (1.2.3)
|
|
55
|
+
reline
|
|
51
56
|
given_core (3.8.2)
|
|
52
57
|
sorcerer (>= 0.3.7)
|
|
53
|
-
guard (2.
|
|
58
|
+
guard (2.20.1)
|
|
54
59
|
formatador (>= 0.2.4)
|
|
55
60
|
listen (>= 2.7, < 4.0)
|
|
61
|
+
logger (~> 1.6)
|
|
56
62
|
lumberjack (>= 1.0.12, < 2.0)
|
|
57
63
|
nenv (~> 0.1)
|
|
58
64
|
notiffany (~> 0.0)
|
|
@@ -64,67 +70,68 @@ GEM
|
|
|
64
70
|
guard (~> 2.1)
|
|
65
71
|
guard-compat (~> 1.1)
|
|
66
72
|
rspec (>= 2.99.0, < 4.0)
|
|
67
|
-
http-2
|
|
68
|
-
httpx (1.
|
|
69
|
-
http-2
|
|
73
|
+
http-2 (1.1.3)
|
|
74
|
+
httpx (1.7.5)
|
|
75
|
+
http-2 (>= 1.1.3)
|
|
70
76
|
ice_nine (0.11.2)
|
|
71
|
-
|
|
77
|
+
io-console (0.8.2)
|
|
78
|
+
listen (3.10.0)
|
|
79
|
+
logger
|
|
72
80
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
|
73
81
|
rb-inotify (~> 0.9, >= 0.9.10)
|
|
74
|
-
|
|
75
|
-
|
|
82
|
+
logger (1.7.0)
|
|
83
|
+
lumberjack (1.4.2)
|
|
84
|
+
method_source (1.1.0)
|
|
76
85
|
nenv (0.3.0)
|
|
77
86
|
notiffany (0.1.3)
|
|
78
87
|
nenv (~> 0.1)
|
|
79
88
|
shellany (~> 0.0)
|
|
80
89
|
pastel (0.8.0)
|
|
81
90
|
tty-color (~> 0.5)
|
|
82
|
-
pry (0.
|
|
91
|
+
pry (0.16.0)
|
|
83
92
|
coderay (~> 1.1)
|
|
84
93
|
method_source (~> 1.0)
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
rake (13.0.6)
|
|
94
|
+
reline (>= 0.6.0)
|
|
95
|
+
rake (13.3.1)
|
|
88
96
|
rb-fsevent (0.11.2)
|
|
89
|
-
rb-inotify (0.
|
|
97
|
+
rb-inotify (0.11.1)
|
|
90
98
|
ffi (~> 1.0)
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
rspec (3.
|
|
94
|
-
rspec-core (~> 3.
|
|
95
|
-
rspec-expectations (~> 3.
|
|
96
|
-
rspec-mocks (~> 3.
|
|
99
|
+
reline (0.6.3)
|
|
100
|
+
io-console (~> 0.5)
|
|
101
|
+
rspec (3.13.2)
|
|
102
|
+
rspec-core (~> 3.13.0)
|
|
103
|
+
rspec-expectations (~> 3.13.0)
|
|
104
|
+
rspec-mocks (~> 3.13.0)
|
|
97
105
|
rspec-collection_matchers (1.2.1)
|
|
98
106
|
rspec-expectations (>= 2.99.0.beta1)
|
|
99
107
|
rspec-context-private (0.0.1)
|
|
100
|
-
rspec-core (3.
|
|
101
|
-
rspec-support (~> 3.
|
|
102
|
-
rspec-expectations (3.
|
|
108
|
+
rspec-core (3.13.6)
|
|
109
|
+
rspec-support (~> 3.13.0)
|
|
110
|
+
rspec-expectations (3.13.5)
|
|
103
111
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
104
|
-
rspec-support (~> 3.
|
|
112
|
+
rspec-support (~> 3.13.0)
|
|
105
113
|
rspec-given (3.8.2)
|
|
106
114
|
given_core (= 3.8.2)
|
|
107
115
|
rspec (>= 2.14.0)
|
|
108
|
-
rspec-its (
|
|
109
|
-
rspec-core (>= 3.
|
|
110
|
-
rspec-expectations (>= 3.
|
|
116
|
+
rspec-its (2.0.0)
|
|
117
|
+
rspec-core (>= 3.13.0)
|
|
118
|
+
rspec-expectations (>= 3.13.0)
|
|
111
119
|
rspec-legacy_formatters (1.0.2)
|
|
112
120
|
rspec (~> 3.0)
|
|
113
|
-
rspec-mocks (3.
|
|
121
|
+
rspec-mocks (3.13.8)
|
|
114
122
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
115
|
-
rspec-support (~> 3.
|
|
116
|
-
rspec-support (3.
|
|
117
|
-
sdoc (2.6.1)
|
|
118
|
-
rdoc (>= 5.0)
|
|
123
|
+
rspec-support (~> 3.13.0)
|
|
124
|
+
rspec-support (3.13.7)
|
|
119
125
|
shellany (0.0.1)
|
|
120
126
|
sorcerer (2.0.1)
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
thor (1.3.0)
|
|
127
|
+
terminal-table (4.0.0)
|
|
128
|
+
unicode-display_width (>= 1.1.1, < 4)
|
|
129
|
+
thor (1.5.0)
|
|
125
130
|
tty-color (0.6.0)
|
|
126
|
-
unicode-display_width (2.
|
|
127
|
-
|
|
131
|
+
unicode-display_width (3.2.0)
|
|
132
|
+
unicode-emoji (~> 4.1)
|
|
133
|
+
unicode-emoji (4.2.0)
|
|
134
|
+
zeitwerk (2.7.5)
|
|
128
135
|
|
|
129
136
|
PLATFORMS
|
|
130
137
|
x86_64-linux
|
|
@@ -144,7 +151,6 @@ DEPENDENCIES
|
|
|
144
151
|
rspec-given
|
|
145
152
|
rspec-its
|
|
146
153
|
rspec-legacy_formatters
|
|
147
|
-
sdoc
|
|
148
154
|
terminal-table
|
|
149
155
|
zeitwerk
|
|
150
156
|
|
data/RAG_SCHEMA.md
ADDED
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
# RAG Schema Module
|
|
2
|
+
|
|
3
|
+
A module to implement a RAG (Retrieval-Augmented Generation) compatible database schema for ArcadeDB.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The `Arcade::Ragschema` module provides a default-index configuration optimized for:
|
|
8
|
+
- **Vector similarity search** (semantic embeddings)
|
|
9
|
+
- **Metadata filtering**
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
The module is included in the gem and automatically available when you require `arcade`.
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
### Basic Setup
|
|
18
|
+
|
|
19
|
+
```ruby
|
|
20
|
+
require 'arcade'
|
|
21
|
+
|
|
22
|
+
module MyApp
|
|
23
|
+
class Document < Arcade::Vertex
|
|
24
|
+
include Arcade::Ragschema
|
|
25
|
+
|
|
26
|
+
attribute :content, Types::String
|
|
27
|
+
attribute :embedding?, Types::Array.of(Types::Float).optional
|
|
28
|
+
attribute :metadata?, Types::Hash.optional
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Create the database type with RAG indexes
|
|
33
|
+
MyApp::Document.create_type
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Custom Schema Configuration
|
|
37
|
+
|
|
38
|
+
```ruby
|
|
39
|
+
module MyApp
|
|
40
|
+
class Document < Arcade::Vertex
|
|
41
|
+
include Arcade::Ragschema
|
|
42
|
+
|
|
43
|
+
attribute :content, Types::String
|
|
44
|
+
attribute :embedding?, Types::Array.of(Types::Float).optional
|
|
45
|
+
attribute :title?, Types::String.optional
|
|
46
|
+
attribute :metadata?, Types::Hash.optional
|
|
47
|
+
|
|
48
|
+
def self.db_init
|
|
49
|
+
# Custom schema with 768-dimensional embeddings
|
|
50
|
+
rag_db_init(vector_dimension: 768)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Inserting Documents with Embeddings
|
|
57
|
+
|
|
58
|
+
```ruby
|
|
59
|
+
# Generate embedding using your preferred service (OpenAI, HuggingFace, etc.)
|
|
60
|
+
embedding = generate_embedding("Your text content here")
|
|
61
|
+
|
|
62
|
+
doc = MyApp::Document.create(
|
|
63
|
+
content: "The content of your document",
|
|
64
|
+
embedding: embedding,
|
|
65
|
+
metadata: {
|
|
66
|
+
author: "John Doe",
|
|
67
|
+
tags: ["ruby", "database"],
|
|
68
|
+
category: "technical"
|
|
69
|
+
},
|
|
70
|
+
source_url: "https://example.com/document",
|
|
71
|
+
created_at: DateTime.now
|
|
72
|
+
)
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Vector Similarity Search
|
|
76
|
+
|
|
77
|
+
Perform semantic search using vector embeddings:
|
|
78
|
+
|
|
79
|
+
```ruby
|
|
80
|
+
# Generate embedding for the query
|
|
81
|
+
query_embedding = generate_embedding("What is a graph database?")
|
|
82
|
+
|
|
83
|
+
# Search for similar documents
|
|
84
|
+
results = MyApp::Document.vector_search(
|
|
85
|
+
query_embedding,
|
|
86
|
+
limit: 10, # Maximum number of results
|
|
87
|
+
threshold: 0.7 # Minimum similarity score (0.0 to 1.0)
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
results.each do |doc|
|
|
91
|
+
puts "#{doc[:content]} (similarity: #{doc[:similarity]})"
|
|
92
|
+
end
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Hybrid Search
|
|
96
|
+
|
|
97
|
+
Combine vector similarity with SQL LIKE text filtering:
|
|
98
|
+
|
|
99
|
+
```ruby
|
|
100
|
+
query_embedding = generate_embedding("graph database")
|
|
101
|
+
|
|
102
|
+
results = MyApp::Document.hybrid_search(
|
|
103
|
+
query_embedding,
|
|
104
|
+
"Ruby programming", # SQL LIKE search term
|
|
105
|
+
limit: 10,
|
|
106
|
+
vector_threshold: 0.7
|
|
107
|
+
)
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Instance Method
|
|
111
|
+
|
|
112
|
+
You can also call `vector_search` on an instance (delegates to class method):
|
|
113
|
+
|
|
114
|
+
```ruby
|
|
115
|
+
doc = MyApp::Document.first
|
|
116
|
+
results = doc.vector_search(query_embedding, limit: 5)
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Schema Details
|
|
120
|
+
|
|
121
|
+
The RAG schema creates the following properties and indexes:
|
|
122
|
+
|
|
123
|
+
### Properties
|
|
124
|
+
- `embedding` - ARRAY_OF_FLOATS type for vector storage
|
|
125
|
+
- `content` - STRING for full document content
|
|
126
|
+
- `metadata` - MAP for flexible metadata
|
|
127
|
+
- `source_url` - STRING for source tracking
|
|
128
|
+
- `created_at` - DATETIME for timestamp
|
|
129
|
+
|
|
130
|
+
### Indexes
|
|
131
|
+
- **LSM_VECTOR** index on `embedding` for similarity search with COSINE similarity
|
|
132
|
+
- **LSM_TREE** index on `metadata` for filtering
|
|
133
|
+
|
|
134
|
+
## Configuration Options
|
|
135
|
+
|
|
136
|
+
### `rag_db_init` Options
|
|
137
|
+
|
|
138
|
+
| Option | Default | Description |
|
|
139
|
+
|--------|---------|-------------|
|
|
140
|
+
| `vector_dimension` | 1536 | Dimension of vector embeddings (OpenAI default) |
|
|
141
|
+
|
|
142
|
+
### `vector_search` Options
|
|
143
|
+
|
|
144
|
+
| Option | Default | Description |
|
|
145
|
+
|--------|---------|-------------|
|
|
146
|
+
| `limit` | 10 | Maximum number of results to return |
|
|
147
|
+
| `threshold` | 0.7 | Minimum similarity score (0.0-1.0) |
|
|
148
|
+
|
|
149
|
+
### `hybrid_search` Options
|
|
150
|
+
|
|
151
|
+
| Option | Default | Description |
|
|
152
|
+
|--------|---------|-------------|
|
|
153
|
+
| `limit` | 10 | Maximum number of results |
|
|
154
|
+
| `vector_threshold` | 0.7 | Minimum vector similarity score |
|
|
155
|
+
|
|
156
|
+
## API Reference
|
|
157
|
+
|
|
158
|
+
### `rag_schema(vector_dimension:)`
|
|
159
|
+
|
|
160
|
+
Returns the SQL commands for creating RAG indexes.
|
|
161
|
+
|
|
162
|
+
```ruby
|
|
163
|
+
schema = MyApp::Document.rag_schema(vector_dimension: 768)
|
|
164
|
+
# => "CREATE INDEX ON my_document (embedding) LSM_VECTOR METADATA {dimensions: 768, similarity: 'COSINE'}\n..."
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### `rag_db_init(vector_dimension:)`
|
|
168
|
+
|
|
169
|
+
Returns the SQL commands for creating properties and indexes. This is typically called from `db_init`.
|
|
170
|
+
|
|
171
|
+
```ruby
|
|
172
|
+
sql = MyApp::Document.rag_db_init(vector_dimension: 768)
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### `.vector_search(query_embedding, limit:, threshold:)`
|
|
176
|
+
|
|
177
|
+
Perform vector similarity search across all documents. Returns metadata only (not embedding vectors) for efficiency.
|
|
178
|
+
|
|
179
|
+
```ruby
|
|
180
|
+
results = MyApp::Document.vector_search(query_embedding, limit: 10, threshold: 0.7)
|
|
181
|
+
# Returns: Array of Hashes with :title, :content, :category, :similarity, etc.
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### `.hybrid_search(query_embedding, text_query, limit:, vector_threshold:)`
|
|
185
|
+
|
|
186
|
+
Perform hybrid search combining vector similarity with SQL LIKE text filtering.
|
|
187
|
+
|
|
188
|
+
```ruby
|
|
189
|
+
results = MyApp::Document.hybrid_search(query_embedding, "search terms", limit: 10, vector_threshold: 0.7)
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### `#vector_search(query_embedding, limit:, threshold:)`
|
|
193
|
+
|
|
194
|
+
Instance method that delegates to the class method.
|
|
195
|
+
|
|
196
|
+
```ruby
|
|
197
|
+
doc = MyApp::Document.first
|
|
198
|
+
results = doc.vector_search(query_embedding, limit: 5)
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Limitations
|
|
202
|
+
|
|
203
|
+
### Full-Text Search
|
|
204
|
+
|
|
205
|
+
**Full-text search is not yet implemented.** The `FULLTEXT` index type is not supported in the current ArcadeDB server version.
|
|
206
|
+
|
|
207
|
+
For text filtering, use the `hybrid_search` method which uses SQL `LIKE` pattern matching instead:
|
|
208
|
+
|
|
209
|
+
```ruby
|
|
210
|
+
# Instead of full-text search, use LIKE-based filtering
|
|
211
|
+
results = MyApp::Document.hybrid_search(
|
|
212
|
+
query_embedding,
|
|
213
|
+
"search term", # Uses: content LIKE '%search term%'
|
|
214
|
+
limit: 10
|
|
215
|
+
)
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Future versions may add support for:
|
|
219
|
+
- Apache Lucene-based full-text indexes
|
|
220
|
+
- Tokenization and stemming
|
|
221
|
+
- Relevance scoring
|
|
222
|
+
|
|
223
|
+
## Example
|
|
224
|
+
|
|
225
|
+
See `examples/rag_usecase_demo.rb` for a complete working example.
|
|
226
|
+
|
|
227
|
+
## Requirements
|
|
228
|
+
|
|
229
|
+
- ArcadeDB server with vector search support (version 23.12+)
|
|
230
|
+
- External embedding service (OpenAI, HuggingFace, etc.) for generating embeddings
|
|
231
|
+
|
|
232
|
+
## Testing
|
|
233
|
+
|
|
234
|
+
Run the RAG schema tests:
|
|
235
|
+
|
|
236
|
+
```bash
|
|
237
|
+
bundle exec rspec spec/lib/rag_schema_spec.rb
|
|
238
|
+
bundle exec rspec spec/lib/usecase/rag_integration_spec.rb
|
|
239
|
+
```
|