okf-search-native 0.7.0 → 0.8.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.
package/README.md CHANGED
@@ -11,11 +11,6 @@ numbers, and snippet.
11
11
  npm install okf-search-native
12
12
  ```
13
13
 
14
- Requires Node.js `>=22.19.0`. Includes TypeScript declarations and native
15
- binaries for macOS x64/arm64 and Linux x64 (glibc >= 2.17); Windows x64 is
16
- experimental. Browsers and Alpine/musl are not supported.
17
- See the [full platform list](https://github.com/robhowley/okf-search/blob/main/packages/okf-search-native/API.md#requirements-and-tested-platforms).
18
-
19
14
  ## Search a collection
20
15
 
21
16
  Given a directory of OKF Markdown files at `./knowledge`:
@@ -223,51 +218,75 @@ console.log(index.listTypes());
223
218
  console.log(index.listDegradedDocuments());
224
219
  ```
225
220
 
226
- ## Performance benchmarks
221
+ ## Benchmarks
227
222
 
228
- Measured on 13,692 Markdown documents (59.57 MiB of source text), using the public
229
- `openOkf` and `search` APIs.
223
+ Compared with `okf-minisearch`, `okf-search-native` had higher Recall@10 and
224
+ lower median latency on both BEIR datasets. On the 100,000-document Natural
225
+ Questions subset, median latency was 92% lower and Recall@10 was 10% higher.
230
226
 
231
- ### Default search options
227
+ ### Datasets
232
228
 
233
- Fuzzy matching is disabled by default; final-term prefix matching remains enabled.
229
+ [Natural Questions (NQ)][beir-nq] uses a 100,000-document Wikipedia subset, not
230
+ the full BEIR corpus. [SciFact][beir-scifact] indexes 5,183 scientific abstracts.
231
+ Both backends searched the same titles and bodies for each dataset.
234
232
 
235
- | Metric | [okf-minisearch][benchmark-minisearch] | [okf-search-native][benchmark-native] |
236
- | --- | ---: | ---: |
237
- | Median `openOkf` time | 20.40 s | 1.57 s |
238
- | Warm query p50 | 10.45 ms | 1.38 ms |
239
- | Warm query p95 | 86.81 ms | 2.38 ms |
240
- | Warm query p99 | 95.64 ms | 2.45 ms |
241
- | Reported index storage¹ | 200.37 MiB | 80.75 MiB |
242
- | Median post-open RSS | 2,235 MiB | 527 MiB |
233
+ | Setup | Natural Questions | SciFact |
234
+ | :--- | ---: | ---: |
235
+ | Documents | 100,000 | 5,183 |
236
+ | Corpus JSONL | 54.0 MiB | 7.7 MiB |
237
+ | Searchable text (titles + bodies) | 47.6 MiB | 7.4 MiB |
238
+ | Quality evaluation queries | 3,452 | 300 |
243
239
 
244
- ### Fuzzy matching enabled
240
+ Changes are relative to MiniSearch and calculated before rounding. Bold marks
241
+ an improvement: higher search quality or lower time, index size, or memory.
242
+ Timings are specific to these workloads.
245
243
 
246
- The same queries and defaults, changing only the search call to:
244
+ ### Quality
247
245
 
248
- ```ts
249
- index.search(query, { fuzzy: true });
250
- ```
246
+ | Metric | NQ MiniSearch | NQ Native | NQ change | SciFact MiniSearch | SciFact Native | SciFact change |
247
+ | :--- | ---: | ---: | ---: | ---: | ---: | ---: |
248
+ | Recall@1 | 40.9% | 46.1% | **+13%** | 42.6% | 46.9% | **+10%** |
249
+ | Recall@3 | 57.2% | 64.0% | **+12%** | 56.4% | 59.1% | **+5%** |
250
+ | Recall@5 | 62.4% | 69.0% | **+11%** | 60.3% | 64.4% | **+7%** |
251
+ | Recall@10 | 67.6% | 74.5% | **+10%** | 67.4% | 71.4% | **+6%** |
252
+ | nDCG@10 | 0.56 | 0.63 | **+12%** | 0.55 | 0.59 | **+7%** |
253
+ | Hit@10 | 68.9% | 75.6% | **+10%** | 69.0% | 73.7% | **+7%** |
254
+
255
+ Hit@10 is the percentage of queries with at least one relevant result in the
256
+ first ten hits.
257
+
258
+ ### Latency
251
259
 
252
- | Metric | [okf-minisearch][benchmark-minisearch] | [okf-search-native][benchmark-native] |
253
- | --- | ---: | ---: |
254
- | Warm query p50 | 14.36 ms | 7.96 ms |
255
- | Warm query p95 | 87.36 ms | 14.12 ms |
256
- | Warm query p99 | 96.71 ms | 15.00 ms |
260
+ | Metric | NQ MiniSearch | NQ Native | NQ change | SciFact MiniSearch | SciFact Native | SciFact change |
261
+ | :--- | ---: | ---: | ---: | ---: | ---: | ---: |
262
+ | Median latency | 458.4 ms | 37.7 ms | **−92%** | 24.7 ms | 16.4 ms | **−33%** |
263
+ | Mean latency | 491.3 ms | 39.4 ms | **−92%** | 27.6 ms | 18.0 ms | **−35%** |
264
+ | p95 latency | 874.4 ms | 64.2 ms | **−93%** | 53.4 ms | 31.9 ms | **−40%** |
265
+ | p99 latency | 1,223.4 ms | 82.1 ms | **−93%** | 74.5 ms | 42.5 ms | **−43%** |
257
266
 
258
- ¹ MiniSearch reports serialized JSON bytes; native reports in-memory Tantivy
259
- index-file bytes. These are different storage representations, not equivalent RAM
260
- measurements. Native storage can vary with background merges.
267
+ ### Index stats
261
268
 
262
- [benchmark-minisearch]: https://github.com/robhowley/okf-search/blob/31d5da38d9502a85101c670729ca1a9646ad3a32/packages/okf-minisearch/package.json
263
- [benchmark-native]: https://github.com/robhowley/okf-search/blob/c187a764b10682919805714faf51d54bf53eb133/packages/okf-search-native/package.json
269
+ | Metric | NQ MiniSearch | NQ Native | NQ change | SciFact MiniSearch | SciFact Native | SciFact change |
270
+ | :--- | ---: | ---: | ---: | ---: | ---: | ---: |
271
+ | Index build time | 37.0 s | 4.7 s | **−87%** | 3.6 s | 0.4 s | **−88%** |
272
+ | Reported index size | 142.2 MiB | 67.1 MiB | **−53%** | 16.6 MiB | 10.3 MiB | **−38%** |
273
+ | Peak process RSS | 3.26 GiB | 0.93 GiB | **−71%** | 0.62 GiB | 0.24 GiB | **−61%** |
264
274
 
265
- ## Reference and development
275
+ [beir-nq]: https://github.com/beir-cellar/beir/blob/ef83d29307061c65d04b035b4f4e7c18bd8374af/README.md?plain=1#L344
276
+ [beir-scifact]: https://github.com/beir-cellar/beir/blob/ef83d29307061c65d04b035b4f4e7c18bd8374af/README.md?plain=1#L358
277
+
278
+ ## Reference
266
279
 
267
280
  - [API reference](https://github.com/robhowley/okf-search/blob/main/packages/okf-search-native/API.md): options, return values, errors, and index statistics.
268
281
  - [Prepared API](https://github.com/robhowley/okf-search/blob/main/packages/okf-search-native/API.md#advanced-prepared-api): for applications that already produce prepared documents.
269
282
  - [Backend differences](https://github.com/robhowley/okf-search/blob/main/packages/okf-search-native/API.md#backend-differences): Tantivy ranking differs from `okf-minisearch`; `autoSuggest` is unsupported.
270
- - [Development](https://github.com/robhowley/okf-search/blob/main/packages/okf-search-native/DEVELOPMENT.md): local builds, tests, and release artifacts.
283
+
284
+ ## Requirements
285
+
286
+ Requires Node.js `>=22.19.0`. Includes TypeScript declarations and native
287
+ binaries for macOS x64/arm64 and Linux x64 (glibc >= 2.17); Windows x64 is
288
+ experimental. Browsers and Alpine/musl are not supported.
289
+ See the [full platform list](https://github.com/robhowley/okf-search/blob/main/packages/okf-search-native/API.md#requirements-and-tested-platforms).
271
290
 
272
291
  ## License
273
292
 
package/native.d.cts CHANGED
@@ -84,14 +84,14 @@ export interface PreparedDocument {
84
84
  documentId: string
85
85
  path: string
86
86
  type: string
87
- conformance: string
87
+ conformance: "strict" | "degraded"
88
88
  diagnostics: Array<Diagnostic>
89
89
  title: string
90
90
  tags: Array<string>
91
- status?: string
91
+ status?: "draft" | "stable" | "deprecated"
92
92
  staleAfterEpoch?: number
93
93
  stalenessClassified: boolean
94
- trustTier?: string
94
+ trustTier?: "unverified" | "machine-confirmed" | "human-reviewed"
95
95
  resource: string
96
96
  description: string
97
97
  sourceText: string
@@ -123,8 +123,8 @@ export interface SearchHit {
123
123
  title: string
124
124
  sectionId: string
125
125
  score: number
126
- conformance: string
127
- matchedFields: Array<string>
126
+ conformance: "strict" | "degraded"
127
+ matchedFields: Array<"resource" | "title" | "heading" | "description" | "tags" | "type" | "sources" | "body">
128
128
  headingPath: string
129
129
  path: string
130
130
  startLine: number
@@ -137,8 +137,8 @@ export interface SearchOptions {
137
137
  snippetLength?: number
138
138
  where?: SearchWhere
139
139
  asOf?: Date
140
- match?: string
141
- fields?: Array<string>
140
+ match?: "any" | "all"
141
+ fields?: Array<"resource" | "title" | "heading" | "description" | "tags" | "type" | "sources" | "body">
142
142
  boost?: SearchBoost
143
143
  fuzzy?: boolean | number
144
144
  }
@@ -146,10 +146,10 @@ export interface SearchOptions {
146
146
  export interface SearchWhere {
147
147
  types?: Array<string>
148
148
  tagsAny?: Array<string>
149
- statuses?: Array<string>
150
- trustTiers?: Array<string>
149
+ statuses?: Array<"draft" | "stable" | "deprecated">
150
+ trustTiers?: Array<"unverified" | "machine-confirmed" | "human-reviewed">
151
151
  stale?: boolean
152
- conformance?: Array<string>
152
+ conformance?: Array<"strict" | "degraded">
153
153
  }
154
154
 
155
155
  export interface Suggestion {
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "okf-search-native",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Search Open Knowledge Format collections at native speed with a lean Rust and Tantivy engine.",
5
5
  "keywords": [
6
6
  "open-knowledge-format",
@@ -77,7 +77,7 @@
77
77
  "test:rust": "cargo test --locked",
78
78
  "test:prepare-bundle": "node ../../scripts/check-private-bundling.mjs native",
79
79
  "typecheck": "pnpm run test:types",
80
- "test": "pnpm run test:prepare-bundle && pnpm run test:types && pnpm run test:package-api && vitest run tests/directory.test.ts tests/lifecycle.test.ts tests/persistence.test.ts tests/raw-boundary.test.ts tests/root-contract.test.ts tests/search-options.test.ts --no-file-parallelism && pnpm run test:rust",
80
+ "test": "pnpm run test:prepare-bundle && pnpm run test:package-api && vitest run tests/directory.test.ts tests/lifecycle.test.ts tests/persistence.test.ts tests/raw-boundary.test.ts tests/root-contract.test.ts tests/search-options.test.ts --no-file-parallelism && pnpm run test:rust",
81
81
  "verify:release-artifacts": "node scripts/verify-release-artifacts.mjs"
82
82
  }
83
83
  }