Convert Figma logo to code with AI

fergiemcdowall logosearch-index

A persistent, network resilient, full text search library for the browser and Node.js

1,384
149
1,384
4

Top Related Projects

9,971

A modern text/numeric/geo-spatial/vector indexing library for go

Official Elasticsearch client library for Node.js

8,902

A bit like Solr, but much smaller and not as bright

Tiny and powerful JavaScript full-text search engine for browser and Node

Next-Generation full text search library for Browser and Node.js

VADER Sentiment Analysis. VADER (Valence Aware Dictionary and sEntiment Reasoner) is a lexicon and rule-based sentiment analysis tool that is specifically attuned to sentiments expressed in social media, and works well on texts from other domains.

Quick Overview

Search-index is a lightweight, full-text search engine for JavaScript applications. It provides a fast and flexible solution for implementing search functionality in both browser and Node.js environments, with support for various indexing and querying options.

Pros

  • Lightweight and easy to integrate into existing projects
  • Supports both browser-side and server-side implementations
  • Offers flexible indexing and querying options
  • Provides good performance for small to medium-sized datasets

Cons

  • May not be suitable for very large datasets or complex search requirements
  • Limited documentation and examples compared to more established search engines
  • Smaller community and ecosystem compared to alternatives like Elasticsearch

Code Examples

  1. Creating and populating an index:
import { Index } from 'search-index'

const index = new Index()

await index.add([
  { id: '1', title: 'First document', body: 'This is the first document' },
  { id: '2', title: 'Second document', body: 'This is the second document' }
])
  1. Performing a simple search:
const results = await index.SEARCH(['document'])
console.log(results)
  1. Using field-specific search:
const results = await index.SEARCH({
  AND: [{ FIELD: 'title', VALUE: 'first' }]
})
console.log(results)
  1. Retrieving documents by ID:
const docs = await index.GET(['1', '2'])
console.log(docs)

Getting Started

To get started with search-index, follow these steps:

  1. Install the package:

    npm install search-index
    
  2. Create a new index and add documents:

    import { Index } from 'search-index'
    
    const index = new Index()
    await index.add([
      { id: '1', title: 'Example', body: 'This is an example document' }
    ])
    
  3. Perform a search:

    const results = await index.SEARCH(['example'])
    console.log(results)
    

Competitor Comparisons

9,971

A modern text/numeric/geo-spatial/vector indexing library for go

Pros of Bleve

  • Written in Go, offering better performance and concurrency support
  • More extensive feature set, including faceted search and highlighting
  • Active development with frequent updates and a larger community

Cons of Bleve

  • Steeper learning curve due to more complex API
  • Higher memory usage, especially for large indexes
  • Requires more setup and configuration compared to Search-index

Code Comparison

Search-index (JavaScript):

const si = require('search-index')
const { index, search } = await si()
await index([{ id: '1', text: 'Hello world' }])
const results = await search('world')

Bleve (Go):

import "github.com/blevesearch/bleve/v2"

index, _ := bleve.New("example.bleve", bleve.NewIndexMapping())
index.Index("1", struct{ Text string }{"Hello world"})
query := bleve.NewMatchQuery("world")
searchResults, _ := index.Search(bleve.NewSearchRequest(query))

Both libraries provide full-text search capabilities, but Bleve offers more advanced features at the cost of increased complexity. Search-index is simpler to use and more lightweight, making it suitable for smaller projects or those with limited resources. Bleve is better suited for larger-scale applications requiring advanced search functionality and performance.

Official Elasticsearch client library for Node.js

Pros of elasticsearch-js

  • Robust and scalable, designed for large-scale distributed search and analytics
  • Supports advanced features like aggregations, geospatial queries, and machine learning
  • Extensive documentation and large community support

Cons of elasticsearch-js

  • Requires more setup and infrastructure compared to search-index
  • Higher learning curve and complexity for simple use cases
  • Resource-intensive, may be overkill for smaller projects

Code Comparison

search-index:

const si = require('search-index')
const { index, search } = await si()
await index([{ id: '1', text: 'Hello world' }])
const results = await search('world')

elasticsearch-js:

const { Client } = require('@elastic/elasticsearch')
const client = new Client({ node: 'http://localhost:9200' })
await client.index({ index: 'myindex', body: { text: 'Hello world' } })
const results = await client.search({ index: 'myindex', body: { query: { match: { text: 'world' } } } })

Both libraries provide indexing and searching capabilities, but elasticsearch-js offers more advanced features and scalability at the cost of increased complexity. search-index is simpler to set up and use for basic search functionality, making it suitable for smaller projects or quick prototypes. elasticsearch-js is better suited for large-scale applications with complex search requirements.

8,902

A bit like Solr, but much smaller and not as bright

Pros of lunr.js

  • Lightweight and easy to set up, with no external dependencies
  • Supports client-side full-text search in the browser
  • Offers flexible search options, including fuzzy matching and boosting

Cons of lunr.js

  • Limited scalability for large datasets compared to search-index
  • Lacks some advanced features like faceted search and range queries
  • May have slower performance for complex queries on larger datasets

Code Comparison

lunr.js:

var idx = lunr(function () {
  this.field('title', { boost: 10 })
  this.field('body')
  this.ref('id')
})

search-index:

const si = require('search-index')
const { index, search } = await si({ name: 'my-index' })
await index([
  { id: '1', title: 'Document 1', body: 'Content 1' },
  { id: '2', title: 'Document 2', body: 'Content 2' }
])

Both libraries provide full-text search capabilities, but they differ in their approach and feature set. lunr.js is more suitable for smaller datasets and client-side search, while search-index offers better scalability and advanced features for larger datasets and server-side implementations.

Tiny and powerful JavaScript full-text search engine for browser and Node

Pros of minisearch

  • Lightweight and fast, with a small bundle size
  • Simple API and easy to use
  • Supports multiple fields and customizable search options

Cons of minisearch

  • Limited advanced features compared to search-index
  • May not be as suitable for large-scale applications
  • Less flexibility in terms of storage and indexing options

Code comparison

minisearch:

const miniSearch = new MiniSearch({
  fields: ['title', 'text'],
  storeFields: ['title', 'category']
})
miniSearch.addAll(documents)
const results = miniSearch.search('query')

search-index:

const si = require('search-index')
const { index, search } = await si()
await index(documents)
const results = await search('query')

Summary

minisearch is a lightweight and easy-to-use search library, ideal for smaller projects and quick implementation. search-index offers more advanced features and flexibility, making it suitable for larger-scale applications. The choice between the two depends on the specific requirements of your project, such as the size of the dataset, needed features, and performance considerations.

Next-Generation full text search library for Browser and Node.js

Pros of FlexSearch

  • Faster performance, especially for large datasets
  • More flexible configuration options for fine-tuning search behavior
  • Supports multiple languages out of the box

Cons of FlexSearch

  • Larger bundle size, which may impact load times in browser environments
  • Steeper learning curve due to more complex API and configuration options
  • Less focus on Node.js server-side usage compared to search-index

Code Comparison

FlexSearch:

const index = new FlexSearch({
  encode: "icase",
  tokenize: "forward",
  threshold: 0,
  resolution: 9
});
index.add(id, text);
const results = index.search("query");

search-index:

const si = require('search-index')
const { index, search } = await si()
await index([{ id: '1', text: 'example' }])
const results = await search('query')

FlexSearch offers more granular control over indexing and searching behavior, while search-index provides a simpler API with fewer configuration options. FlexSearch is generally faster and more flexible, but search-index may be easier to integrate for basic use cases, especially in Node.js environments.

VADER Sentiment Analysis. VADER (Valence Aware Dictionary and sEntiment Reasoner) is a lexicon and rule-based sentiment analysis tool that is specifically attuned to sentiments expressed in social media, and works well on texts from other domains.

Pros of VADER Sentiment

  • Specifically designed for sentiment analysis of social media text
  • Requires no training data and works out-of-the-box
  • Provides sentiment intensity scores (positive, negative, neutral, compound)

Cons of VADER Sentiment

  • Limited to sentiment analysis, not a full-text search solution
  • May not perform as well on formal or domain-specific text
  • Less flexibility for customization compared to search-index

Code Comparison

VADER Sentiment usage:

from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer

analyzer = SentimentIntensityAnalyzer()
sentiment = analyzer.polarity_scores("Hello world!")
print(sentiment)

search-index usage:

const si = require('search-index')
const { index, search } = await si()

await index([{ id: '1', text: 'Hello world!' }])
const results = await search('hello')
console.log(results)

While VADER Sentiment focuses on sentiment analysis, search-index provides full-text search capabilities. VADER Sentiment is more suitable for quick sentiment analysis tasks, especially on social media content. search-index offers broader functionality for indexing and searching text data, making it more versatile for general search applications.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

search-index

A network resilient, persistent full-text search library for the browser and Node.js

npm npm license Build Status JavaScript Style Guide

Quick start

import { SearchIndex } from 'search-index' 

// initialize an index
const { PUT, QUERY } = new SearchIndex(options)

// add documents to the index
await PUT(documents)

// read documents from the index
const results = await QUERY(query)

Documentation

NPM DownloadsLast 30 Days