document-dataply 0.0.5 → 0.0.7-alpha.0

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.
@@ -35,6 +35,11 @@ export declare class DocumentDataplyAPI<T extends DocumentJSON, IC extends Index
35
35
  getDocumentMetadata(tx: Transaction): Promise<DocumentDataplyMetadata>;
36
36
  getDocumentInnerMetadata(tx: Transaction): Promise<DocumentDataplyInnerMetadata>;
37
37
  updateDocumentInnerMetadata(metadata: DocumentDataplyInnerMetadata, tx: Transaction): Promise<void>;
38
+ /**
39
+ * Transforms a query object into a verbose query object
40
+ * @param query The query object to transform
41
+ * @returns The verbose query object
42
+ */
38
43
  verboseQuery<U extends Partial<DocumentDataplyIndexedQuery<T, IC>>, V extends DataplyTreeValue<U>>(query: Partial<DocumentDataplyQuery<U>>): Partial<DocumentDataplyQuery<V>>;
39
44
  /**
40
45
  * Get the selectivity candidate for the given query
@@ -47,11 +52,15 @@ export declare class DocumentDataplyAPI<T extends DocumentJSON, IC extends Index
47
52
  tree: BPTreeAsync<number, V>;
48
53
  condition: Partial<DocumentDataplyCondition<U>>;
49
54
  field: string;
55
+ isFtsMatch?: boolean;
56
+ matchTokens?: string[];
50
57
  };
51
58
  others: {
52
59
  tree: BPTreeAsync<number, V>;
53
60
  condition: Partial<DocumentDataplyCondition<U>>;
54
61
  field: string;
62
+ isFtsMatch?: boolean;
63
+ matchTokens?: string[];
55
64
  }[];
56
65
  rollback: () => void;
57
66
  } | null>;
@@ -63,9 +72,15 @@ export declare class DocumentDataplyAPI<T extends DocumentJSON, IC extends Index
63
72
  verySmallChunkSize: number;
64
73
  smallChunkSize: number;
65
74
  };
75
+ private getTokenKey;
76
+ private applyCandidateByFTS;
66
77
  /**
67
- * Get Primary Keys based on query and index selection.
68
- * Internal common method to unify query optimization.
78
+ * 특정 인덱스 후보를 조회하여 PK 집합을 필터링합니다.
79
+ */
80
+ private applyCandidate;
81
+ /**
82
+ * 쿼리와 인덱스 선택을 기반으로 기본 키(Primary Keys)를 가져옵니다.
83
+ * 쿼리 최적화를 통합하기 위한 내부 공통 메서드입니다.
69
84
  */
70
85
  getKeys(query: Partial<DocumentDataplyIndexedQuery<T, IC>>, orderBy?: keyof IC | '_id', sortOrder?: 'asc' | 'desc'): Promise<Float64Array>;
71
86
  private insertDocumentInternal;
@@ -121,6 +136,19 @@ export declare class DocumentDataplyAPI<T extends DocumentJSON, IC extends Index
121
136
  * @returns The number of documents that match the query
122
137
  */
123
138
  countDocuments(query: Partial<DocumentDataplyIndexedQuery<T, IC>>, tx?: Transaction): Promise<number>;
139
+ /**
140
+ * FTS 조건에 대해 문서가 유효한지 검증합니다.
141
+ */
142
+ private verifyFts;
143
+ /**
144
+ * 메모리 기반으로 청크 크기를 동적 조절합니다.
145
+ */
146
+ private adjustChunkSize;
147
+ /**
148
+ * Prefetch 방식으로 키 배열을 청크 단위로 조회하여 문서를 순회합니다.
149
+ * FTS 검증을 통과한 문서만 yield 합니다.
150
+ */
151
+ private processChunkedKeys;
124
152
  /**
125
153
  * Select documents from the database
126
154
  * @param query The query to use (only indexed fields + _id allowed)
@@ -16,7 +16,17 @@ export interface DocumentDataplyInnerMetadata {
16
16
  updatedAt: number;
17
17
  lastId: number;
18
18
  indices: {
19
- [key: string]: [number, boolean];
19
+ [key: string]: [
20
+ number,
21
+ boolean | {
22
+ type: 'fts';
23
+ tokenizer: 'whitespace';
24
+ } | {
25
+ type: 'fts';
26
+ tokenizer: 'ngram';
27
+ gramSize: number;
28
+ }
29
+ ];
20
30
  };
21
31
  }
22
32
  export interface DocumentDataplyMetadata {
@@ -46,6 +56,7 @@ export type DocumentDataplyCondition<V> = {
46
56
  notEqual?: Partial<V>;
47
57
  or?: Partial<V>[];
48
58
  like?: string;
59
+ match?: string;
49
60
  };
50
61
  export type DocumentDataplyQuery<T> = {
51
62
  [key in keyof T]?: T[key] | DocumentDataplyCondition<T[key]>;
@@ -110,10 +121,18 @@ export type DocumentDataplyIndices<T extends DocumentJSON, IC extends IndexConfi
110
121
  [key in keyof IC & keyof FinalFlatten<T>]: GetTypeByPath<T, key>;
111
122
  };
112
123
  /**
113
- * Index configuration type - keys are field names, values are boolean
124
+ * Index configuration type
114
125
  */
126
+ export type FTSConfig = {
127
+ type: 'fts';
128
+ tokenizer: 'whitespace';
129
+ } | {
130
+ type: 'fts';
131
+ tokenizer: 'ngram';
132
+ gramSize: number;
133
+ };
115
134
  export type IndexConfig<T> = Partial<{
116
- [key in keyof FinalFlatten<T>]: boolean;
135
+ [key in keyof FinalFlatten<T>]: boolean | FTSConfig;
117
136
  }>;
118
137
  /**
119
138
  * Extract index keys from IndexConfig
@@ -0,0 +1 @@
1
+ export declare function fastStringHash(str: string): number;
@@ -0,0 +1,4 @@
1
+ import { FTSConfig } from '../types';
2
+ export declare function whitespaceTokenize(text: string): string[];
3
+ export declare function ngramTokenize(text: string, gramSize: number): string[];
4
+ export declare function tokenize(text: string, options: FTSConfig): string[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "document-dataply",
3
- "version": "0.0.5",
3
+ "version": "0.0.7-alpha.0",
4
4
  "description": "Simple and powerful JSON document database supporting complex queries and flexible indexing policies.",
5
5
  "license": "MIT",
6
6
  "author": "izure <admin@izure.org>",
@@ -42,7 +42,7 @@
42
42
  "dataply"
43
43
  ],
44
44
  "dependencies": {
45
- "dataply": "^0.0.21"
45
+ "dataply": "^0.0.23-alpha.2"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@types/jest": "^30.0.0",