Class: MossClient
MossClient - Local semantic search client for vector similarity operations.Example
Constructors
Constructor
new MossClient(Creates a new MossClient instance for local operations.projectId,projectKey):MossClient
Parameters
projectId
string
Your project identifier.
projectKey
string
Your project authentication key.
Returns
MossClient
Methods
createIndex()
createIndex(Creates a new index with the provided documents.indexName,docs,modelId):Promise<boolean>
Parameters
indexName
string
Name of the index to create.
docs
DocumentInfo[]
Initial documents to add to the index.
modelId
string
Model to use for embeddings.
Returns
Promise<boolean>
Promise that resolves to true if successful.
Throws
If the index already exists or creation fails.Example
getIndex()
getIndex(Gets information about a specific index.indexName):Promise<IndexInfo>
Parameters
indexName
string
Name of the index to retrieve.
Returns
Promise<IndexInfo>
Promise that resolves to IndexInfo object.
Throws
If the index does not exist.Example
listIndexes()
listIndexes():Lists all available indexes.Promise<IndexInfo[]>
Returns
Promise<IndexInfo[]>
Promise that resolves to array of IndexInfo objects.
Example
deleteIndex()
deleteIndex(Deletes an index and all its data.indexName):Promise<boolean>
Parameters
indexName
string
Name of the index to delete.
Returns
Promise<boolean>
Promise that resolves to true if successful.
Throws
If the index does not exist.Example
addDocs()
addDocs(Adds or updates documents in an index.indexName,docs,options?):Promise<{added:number;updated:number; }>
Parameters
indexName
string
Name of the target index.
docs
DocumentInfo[]
Documents to add or update.
options?
AddDocumentsOptions
Optional configuration for the operation.
Returns
Promise<{ added: number; updated: number; }>
Promise that resolves to operation result with counts.
Throws
If the index does not exist.Example
deleteDocs()
deleteDocs(Deletes documents from an index by their IDs.indexName,docIds):Promise<{deleted:number; }>
Parameters
indexName
string
Name of the target index.
docIds
string[]
Array of document IDs to delete.
Returns
Promise<{ deleted: number; }>
Promise that resolves to operation result with count.
Throws
If the index does not exist.Example
getDocs()
getDocs(Retrieves documents from an index.indexName,options?):Promise<DocumentInfo[]>
Parameters
indexName
string
Name of the target index.
options?
GetDocumentsOptions
Optional configuration for retrieval.
Returns
Promise<DocumentInfo[]>
Promise that resolves to array of documents.
Throws
If the index does not exist.Example
loadIndex()
loadIndex(Loads an index from a local .moss file.indexName):Promise<string>
Parameters
indexName
string
Name of the index to load.
Returns
Promise<string>
Promise that resolves to the index name.
Throws
If the index file does not exist or is invalid.Example
query()
query(Performs a semantic similarity search against the specified index.indexName,query,topK?):Promise<SearchResult>
Parameters
indexName
string
Name of the target index to search.
query
string
The search query text.
topK?
number
Maximum number of results to return (default: 5).
Returns
Promise<SearchResult>
Promise that resolves to SearchResult with matching documents.