norasearch
norasearch · NoraSearch is a high-performance search engine for PostgreSQL.
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 101201 | norasearch | norasearch | 1.0 | FTS | MIT | C |
PostgreSQL · 16, 17, 18
Usage
Sources:
- Official README at the reviewed commit
- Version 1.0 SQL declaration
- Matching implementation
- Extension control file
norasearch provides one byte-oriented similarity function. At every nonnegative alignment of a needle against a haystack, it counts equal byte positions and returns the alignments whose count is strictly greater than a threshold. This is cross-correlation-like scoring, not ordinary contiguous substring search.
Core Workflow
The signature is norasearch(hay text, needle text, minmatch int) RETURNS int[][]. Each result row is {offset,count}. offset is zero-based and only offsets from the beginning of the haystack onward are considered. A negative minmatch is treated as zero; matching uses the strict condition count > minmatch.
Result and Performance Boundaries
The function is strict for SQL NULL input. Empty strings, no qualifying alignment, or other zero-result cases return NULL, not an empty array. The implementation compares raw bytes, so offsets are byte positions and multibyte UTF-8 characters can be split; do not interpret them as character indexes.
There is no index operator class or planner integration. The implementation examines each haystack position against the needle, giving worst-case work proportional to both lengths and allocating result arrays per call. Benchmark large or repetitive values before applying norasearch across many rows.