On this page
Overview
Dependency-free deterministic document indexing, complete ranked metadata/body search, complete excerpts, and stable tie-breaking.
- Artifact
DocumentLexicalSearch.js· esm - Classification
public first party - Availability
Cross-host in-process only - Normalization
Normalizes text and filters, preserves deterministic field priority, and returns complete mutable results without network, storage, or provider side effects.
Import and lifecycle
import * as module from '/arcane/modules/DocumentLexicalSearch.js';
Construction creates mutable in-memory indexes. Tokenization, scoring, rank, search, and excerpt helpers are deterministic and perform no storage, network, provider, DOM, or global mutation.
Application-facing behavior: Search-field constant; DocumentLexicalSearch; index/token/score/excerpt helpers; complete rank() and search().
Protocol and host implementation
In-process mutable record contract This detail does not widen the application-facing API or grant authority.
Exports, signatures, parameters, and results
| Binding | Form | Declaration or signature | Parameter syntax |
|---|---|---|---|
DOCUMENT_SEARCH_FIELD_ORDER | variable · value | variable DOCUMENT_SEARCH_FIELD_ORDER | — |
DocumentLexicalSearch | class | class DocumentLexicalSearch | — |
createDocumentLexicalIndex | function | function createDocumentLexicalIndex(record) | record |
documentContextExcerpt | function | function documentContextExcerpt(value) | value |
documentSearchTokens | function | function documentSearchTokens(value) | value |
normalizedDocumentSearchText | function | function normalizedDocumentSearchText(value) | value |
scoreDocumentBody | function | function scoreDocumentBody(value,phrase,tokens) | value,phrase,tokens |
scoreDocumentLexicalIndex | function | function scoreDocumentLexicalIndex(index,phrase,tokens) | index,phrase,tokens |
default | default · class | class DocumentLexicalSearch | — |
| Callable | Kind | Exact public signature | Parameter syntax |
|---|---|---|---|
createDocumentLexicalIndex | exported-function | function createDocumentLexicalIndex(record) | record |
documentContextExcerpt | exported-function | function documentContextExcerpt(value) | value |
documentSearchTokens | exported-function | function documentSearchTokens(value) | value |
normalizedDocumentSearchText | exported-function | function normalizedDocumentSearchText(value) | value |
scoreDocumentBody | exported-function | function scoreDocumentBody(value,phrase,tokens) | value,phrase,tokens |
scoreDocumentLexicalIndex | exported-function | function scoreDocumentLexicalIndex(index,phrase,tokens) | index,phrase,tokens |
DocumentLexicalSearch.rank | public-member | rank(query,options={}) | query,options={} |
DocumentLexicalSearch.search | public-member | search(query,options={}) | query,options={} |
| Member | Kind | Exact public declaration | Parameter syntax |
|---|---|---|---|
DocumentLexicalSearch.constructor | constructor | constructor(records) | records |
DocumentLexicalSearch.rank | method | rank(query,options={}) | query,options={} |
DocumentLexicalSearch.search | method | search(query,options={}) | query,options={} |
Parameter meanings and results
new DocumentLexicalSearch(records); rank(query,{kinds,tags}) and search(query,{kinds,tags}) return every mutable scored match. documentContextExcerpt(value) returns the complete text and full line range. Public helpers expose normalized text/tokens, index construction, and metadata/body scoring.
Events, side effects, and errors
Source-literal CustomEvent dispatches
No source-literal CustomEvent dispatch is part of this artifact.
Lifecycle and event flow
This artifact has no additional documented lifecycle event flow.
Direct coded failures
This artifact directly assigns no stable coded failure.
Exported Error subclasses
This artifact exports no Error subclass.
Documented failure behavior
- DOCUMENT_SEARCH_INVALID
- DOCUMENT_SEARCH_INVALID_QUERY
Availability and capabilities
Cross-host in-process only. Normalizes text and filters, preserves deterministic field priority, and returns complete mutable results without network, storage, or provider side effects.
Dependency-free cross-host search with no Core or provider authority. Applications decide which records enter the index and whether results become chat context.
Contract example
import {DocumentLexicalSearch} from '/arcane/modules/DocumentLexicalSearch.js';
const search=new DocumentLexicalSearch([{
id:'welcome',title:'Welcome',body:'Arcane apps are portable.',
path:'welcome.md',kind:'guide',tags:['intro']
}]);
console.log(search.search('portable',{limit:5}));
Related reference
No direct Core call is claimed for this artifact. Any injected provider or consuming module retains its own documented authority.