Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

typesense

Package Overview
Dependencies
Maintainers
2
Versions
169
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typesense

Javascript Library for Typesense

  • 2.0.0-4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
115K
decreased by-22.8%
Maintainers
2
Weekly downloads
 
Created

What is typesense?

Typesense is an open-source, typo-tolerant search engine optimized for instant search-as-you-type experiences and designed to be easy to use and integrate. It provides a simple API for indexing and searching documents, making it suitable for applications that require fast and relevant search results.

What are typesense's main functionalities?

Indexing Documents

This feature allows you to create a schema and index documents into a collection. The code sample demonstrates how to create a client, define a schema, and create a collection in Typesense.

const Typesense = require('typesense');

let client = new Typesense.Client({
  nodes: [{
    host: 'localhost',
    port: '8108',
    protocol: 'http'
  }],
  apiKey: 'xyz',
  connectionTimeoutSeconds: 2
});

let schema = {
  'name': 'companies',
  'fields': [
    {'name': 'company_name', 'type': 'string' },
    {'name': 'num_employees', 'type': 'int32' },
    {'name': 'country', 'type': 'string' }
  ]
};

client.collections().create(schema).then(function(data) {
  console.log(data);
});

Searching Documents

This feature allows you to search for documents within a collection. The code sample demonstrates how to perform a search query on the 'companies' collection, searching by the 'company_name' field.

client.collections('companies').documents().search({
  'q': 'Typesense',
  'query_by': 'company_name'
}).then(function (searchResults) {
  console.log(searchResults);
});

Updating Documents

This feature allows you to update existing documents in a collection. The code sample demonstrates how to update a document with a specific ID in the 'companies' collection.

client.collections('companies').documents('123').update({
  'company_name': 'Typesense Inc.',
  'num_employees': 50,
  'country': 'USA'
}).then(function (data) {
  console.log(data);
});

Deleting Documents

This feature allows you to delete documents from a collection. The code sample demonstrates how to delete a document with a specific ID from the 'companies' collection.

client.collections('companies').documents('123').delete().then(function (data) {
  console.log(data);
});

Other packages similar to typesense

Keywords

FAQs

Package last updated on 29 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc