Capability first · transport second

DocumentLexicalSearch.js

Dependency-free deterministic document indexing, complete ranked metadata/body search, complete excerpts, and stable tie-breaking.

SDK 0.5.18Runtime 0.8.12Protocol arcane/1
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

JavaScript
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

BindingFormDeclaration or signatureParameter syntax
DOCUMENT_SEARCH_FIELD_ORDERvariable · valuevariable DOCUMENT_SEARCH_FIELD_ORDER
DocumentLexicalSearchclassclass DocumentLexicalSearch
createDocumentLexicalIndexfunctionfunction createDocumentLexicalIndex(record)record
documentContextExcerptfunctionfunction documentContextExcerpt(value)value
documentSearchTokensfunctionfunction documentSearchTokens(value)value
normalizedDocumentSearchTextfunctionfunction normalizedDocumentSearchText(value)value
scoreDocumentBodyfunctionfunction scoreDocumentBody(value,phrase,tokens)value,phrase,tokens
scoreDocumentLexicalIndexfunctionfunction scoreDocumentLexicalIndex(index,phrase,tokens)index,phrase,tokens
defaultdefault · classclass DocumentLexicalSearch
CallableKindExact public signatureParameter syntax
createDocumentLexicalIndexexported-functionfunction createDocumentLexicalIndex(record)record
documentContextExcerptexported-functionfunction documentContextExcerpt(value)value
documentSearchTokensexported-functionfunction documentSearchTokens(value)value
normalizedDocumentSearchTextexported-functionfunction normalizedDocumentSearchText(value)value
scoreDocumentBodyexported-functionfunction scoreDocumentBody(value,phrase,tokens)value,phrase,tokens
scoreDocumentLexicalIndexexported-functionfunction scoreDocumentLexicalIndex(index,phrase,tokens)index,phrase,tokens
DocumentLexicalSearch.rankpublic-memberrank(query,options={})query,options={}
DocumentLexicalSearch.searchpublic-membersearch(query,options={})query,options={}
MemberKindExact public declarationParameter syntax
DocumentLexicalSearch.constructorconstructorconstructor(records)records
DocumentLexicalSearch.rankmethodrank(query,options={})query,options={}
DocumentLexicalSearch.searchmethodsearch(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

JavaScript
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}));

No direct Core call is claimed for this artifact. Any injected provider or consuming module retains its own documented authority.