MossClient
Local semantic search client for vector similarity operations.Quick Example
Constructor
new MossClient()
| Name | Type | Required | Description |
|---|---|---|---|
projectId | string | Yes | Your project identifier. |
projectKey | string | Yes | Your project authentication key. |
MossClient
Methods
createIndex()
| Name | Type | Required | Description |
|---|---|---|---|
indexName | string | Yes | Name of the index to create. |
docs | DocumentInfo[] | Yes | Initial documents to add to the index. |
modelId | string | Yes | Model to use for embeddings. |
Promise<boolean> - Promise that resolves to true if successful.
Throws
If the index already exists or creation fails.
Example
getIndex()
| Name | Type | Required | Description |
|---|---|---|---|
indexName | string | Yes | Name of the index to retrieve. |
Promise<IndexInfo> - Promise that resolves to IndexInfo object.
Throws
If the index does not exist.
Example
listIndexes()
Promise<IndexInfo[]> - Promise that resolves to array of IndexInfo objects.
Example
deleteIndex()
| Name | Type | Required | Description |
|---|---|---|---|
indexName | string | Yes | Name of the index to delete. |
Promise<boolean> - Promise that resolves to true if successful.
Throws
If the index does not exist.
Example
loadIndex()
| Name | Type | Required | Description |
|---|---|---|---|
indexName | string | Yes | Name of the index to load. |
Promise<string> - Promise that resolves to the index name.
Throws
If the index file does not exist or is invalid.
Example
addDocs()
| Name | Type | Required | Description |
|---|---|---|---|
indexName | string | Yes | Name of the target index. |
docs | DocumentInfo[] | Yes | Documents to add or update. |
options | AddDocumentsOptions | No | Optional configuration for the operation. |
Promise<{ added: number; updated: number; }> - Promise that resolves to operation result with counts.
Throws
If the index does not exist.
Example
deleteDocs()
| Name | Type | Required | Description |
|---|---|---|---|
indexName | string | Yes | Name of the target index. |
docIds | string[] | Yes | Array of document IDs to delete. |
Promise<{ deleted: number; }> - Promise that resolves to operation result with count.
Throws
If the index does not exist.
Example
getDocs()
| Name | Type | Required | Description |
|---|---|---|---|
indexName | string | Yes | Name of the target index. |
options | GetDocumentsOptions | No | Optional configuration for retrieval. |
Promise<DocumentInfo[]> - Promise that resolves to array of documents.
Throws
If the index does not exist.
Example
query()
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
indexName | string | Yes | - | Name of the target index to search. |
query | string | Yes | - | The search query text. |
topK | number | No | 5 | Maximum number of results to return. |
Promise<SearchResult> - Promise that resolves to SearchResult with matching documents.
Throws
If the specified index does not exist.
Example