2
2
Class RAG .IFindSetup
3
3
{
4
4
5
- /// Create a new table with iFind support since we can't alter existing table
5
+ /// Create persistent class table for iFind functionality
6
6
ClassMethod CreateIFindTable () As %Status
7
7
{
8
8
Try {
9
- Write " Creating new table with iFind support ..." ,!
9
+ Write " Setting up iFind table using persistent class ..." ,!
10
10
11
- // Create a new table that mirrors SourceDocuments but with iFind
12
- &sql (CREATE TABLE RAG .SourceDocumentsIFind (
13
- doc_id VARCHAR (200 ) PRIMARY KEY ,
14
- title VARCHAR (500 ),
15
- text_content LONGVARCHAR,
16
- authors LONGVARCHAR,
17
- keywords LONGVARCHAR,
18
- embedding VARCHAR (32000 ),
19
- created_at TIMESTAMP
20
- ))
21
-
22
- If SQLCODE '= 0 {
23
- Write " Error creating table: SQLCODE=" , SQLCODE , " MSG=" , %msg ,!
24
- Return $$$ERROR($$$GeneralError, " Failed to create table" )
11
+ // Compile the SourceDocumentsWithIFind class to create table
12
+ Set status = $System .OBJ .Compile (" RAG.SourceDocumentsWithIFind.cls" , " ck" )
13
+ If $$$ISERR(status ) {
14
+ Write " Error compiling class: " , $System .Status .GetErrorText (status ),!
15
+ Return status
25
16
}
26
17
27
- Write " Table created successfully" ,!
28
-
29
- // Now add the iFind index using ALTER TABLE
30
- Write " Adding iFind index..." ,!
31
- &sql (ALTER TABLE RAG .SourceDocumentsIFind ADD FULLTEXT INDEX idx_ifind (text_content))
18
+ Write " ✅ iFind table class compiled successfully" ,!
32
19
33
- If SQLCODE '= 0 {
34
- Write " Error creating iFind index: SQLCODE=" , SQLCODE , " MSG=" , %msg ,!
35
- // Try alternative syntax
36
- Write " Trying alternative syntax..." ,!
37
- &sql (CREATE FULLTEXT INDEX idx_ifind ON RAG .SourceDocumentsIFind (text_content))
38
-
39
- If SQLCODE '= 0 {
40
- Write " Still failed: SQLCODE=" , SQLCODE , " MSG=" , %msg ,!
41
- Return $$$ERROR($$$GeneralError, " Failed to create iFind index" )
42
- }
20
+ // Test that the table was created
21
+ &sql (SELECT COUNT (* ) INTO :count FROM RAG .SourceDocumentsWithIFind )
22
+ If SQLCODE = 0 {
23
+ Write " ✅ Table created and accessible" ,!
24
+ } Else {
25
+ Write " Table creation verification failed: SQLCODE=" , SQLCODE ,!
43
26
}
44
27
45
- Write " ✅ iFind index created successfully!" ,!
46
28
Return $$$OK
47
29
48
30
} Catch ex {
@@ -57,8 +39,11 @@ ClassMethod CopyDataToIFindTable() As %Status
57
39
Try {
58
40
Write " Copying data to iFind table..." ,!
59
41
60
- &sql (INSERT INTO RAG .SourceDocumentsIFind
61
- SELECT * FROM RAG .SourceDocuments )
42
+ // Use INSERT with explicit column mapping for compatibility
43
+ &sql (INSERT INTO RAG .SourceDocumentsWithIFind
44
+ (doc_id, title, text_content, authors, keywords, embedding, created_at)
45
+ SELECT doc _id , title , text _content , authors , keywords , embedding , created _at
46
+ FROM RAG .SourceDocuments )
62
47
63
48
If SQLCODE = 0 {
64
49
Write " ✅ Copied " , %ROWCOUNT , " documents" ,!
@@ -74,16 +59,16 @@ ClassMethod CopyDataToIFindTable() As %Status
74
59
}
75
60
}
76
61
77
- /// Test iFind search using %CONTAINS
62
+ /// Test iFind search using %FIND
78
63
ClassMethod TestIFindSearch (searchText As %String ) As %Status
79
64
{
80
65
Try {
81
66
Write !," Searching for: " , searchText ,!,!
82
67
83
68
&sql (DECLARE C1 CURSOR FOR
84
69
SELECT TOP 10 doc_id, title
85
- FROM RAG .SourceDocumentsIFind
86
- WHERE %CONTAINS (text_content, :searchText))
70
+ FROM RAG .SourceDocumentsWithIFind
71
+ WHERE %FIND (text_content, :searchText) > 0 )
87
72
88
73
&sql (OPEN C1)
89
74
@@ -131,8 +116,8 @@ ClassMethod Setup() As %Status
131
116
132
117
Write !," ✅ Setup complete!" ,!
133
118
Write " Update hybrid_ifind_rag/pipeline.py to use:" ,!
134
- Write " FROM RAG.SourceDocumentsIFind " ,!
135
- Write " WHERE %CONTAINS (text_content, ?)" ,!
119
+ Write " FROM RAG.SourceDocumentsWithIFind " ,!
120
+ Write " WHERE %FIND (text_content, ?) > 0 " ,!
136
121
137
122
Return $$$OK
138
123
}
0 commit comments