Interface: ISearchEngine
Defined in: src/types/interfaces/search.interface.ts:262
Search engine interface for Elasticsearch.
Remarks
Provides full-text search, faceted search, and autocomplete for preprints.
Implementation notes:
- Uses Elasticsearch 8+
- Indices prefixed with
chive-preprints- - Ingest pipeline for PDF text extraction
- Custom analyzers for academic text
Methods
autocomplete()
autocomplete(
prefix,limit?):Promise<readonlystring[]>
Defined in: src/types/interfaces/search.interface.ts:367
Provides autocomplete suggestions.
Parameters
prefix
string
Partial query string
limit?
number
Maximum number of suggestions
Returns
Promise<readonly string[]>
Suggested completions
Remarks
Uses Elasticsearch completion suggester for fast autocomplete. Suggestions are based on indexed titles and keywords.
Example
const suggestions = await searchEngine.autocomplete('neura', 5);
// ['neural', 'neural networks', 'neuromorphic', ...]
deleteDocument()
deleteDocument(
uri):Promise<void>
Defined in: src/types/interfaces/search.interface.ts:387
Removes a document from the index.
Parameters
uri
Document URI
Returns
Promise<void>
Promise resolving when deleted
Remarks
Use when a preprint is deleted from the user's PDS.
Example
await searchEngine.deleteDocument(
toAtUri('at://did:plc:abc/pub.chive.preprint.submission/xyz')!
);
facetedSearch()
facetedSearch(
query):Promise<FacetedSearchResults>
Defined in: src/types/interfaces/search.interface.ts:346
Performs faceted search with aggregations.
Parameters
query
Faceted search query
Returns
Promise<FacetedSearchResults>
Results with facet counts
Remarks
Extends regular search with aggregation results for each facet dimension. Use for browse interfaces with faceted navigation.
Example
const results = await searchEngine.facetedSearch({
q: 'neural networks',
facets: ['subjects', 'year'],
limit: 20
});
console.log('Subjects:', results.facets.subjects);
// [{ value: "Computer Science", count: 150 }, ...]
indexPreprint()
indexPreprint(
preprint):Promise<void>
Defined in: src/types/interfaces/search.interface.ts:290
Indexes a preprint document.
Parameters
preprint
Preprint to index
Returns
Promise<void>
Promise resolving when indexed
Remarks
Indexes or updates the preprint in Elasticsearch. If full-text extraction is enabled, triggers PDF processing via ingest pipeline.
Example
await searchEngine.indexPreprint({
uri: toAtUri('at://did:plc:abc/pub.chive.preprint.submission/xyz')!,
author: toDID('did:plc:abc')!,
authorName: 'Dr. Jane Smith',
title: 'Neural Networks in Biology',
abstract: 'This paper explores...',
keywords: ['neural networks', 'biology'],
subjects: ['Computer Science', 'Biology'],
createdAt: new Date(),
indexedAt: new Date()
});
search()
search(
query):Promise<SearchResults>
Defined in: src/types/interfaces/search.interface.ts:320
Searches preprints.
Parameters
query
Search query
Returns
Promise<SearchResults>
Search results
Remarks
Performs full-text search across title, abstract, and full-text (if available). Returns results sorted by relevance score.
Example
const results = await searchEngine.search({
q: 'neural networks biology',
filters: {
subjects: ['Computer Science'],
dateFrom: new Date('2024-01-01')
},
limit: 20
});
results.hits.forEach(hit => {
console.log(`${hit.uri} (score: ${hit.score})`);
});