Skip to content

About

A full text search API using NodeJS and OpenSearch

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

OpenSearch API

Simple Node.js API to connect and search in OpenSearch.

Installation

npm install

Usage

1. Start OpenSearch

docker-compose up -d

2. Start the API

npm start

For development (with nodemon):

npm run dev

Endpoints

1. Search (main)

GET /search?query=term&index=index_name

Example:

curl "http://localhost:3000/search?query=test"

2. Health check

GET /health

3. Create document

POST /document
Content-Type: application/json

{
  "index": "documents",
  "document": {
    "title": "My document",
    "content": "Document content",
    "created_at": "2024-01-01"
  }
}

4. Homepage

GET /

Configuration

Default settings are in the code, but you can use environment variables:

  • OPENSEARCH_URL: OpenSearch URL (default: https://localhost:9200)
  • OPENSEARCH_USERNAME: Username (default: admin)
  • OPENSEARCH_PASSWORD: Password (default: OpenSearch2024!Strong)
  • PORT: API port (default: 3000)

Complete usage example

# 1. Create a document
curl -X POST http://localhost:3000/document \
  -H "Content-Type: application/json" \
  -d '{
    "index": "articles",
    "document": {
      "title": "Introduction to OpenSearch",
      "content": "OpenSearch is a search and analytics tool...",
      "author": "John Doe",
      "date": "2024-01-15"
    }
  }'

# 2. Search documents
curl "http://localhost:3000/search?query=OpenSearch&index=articles"

About

A full text search API using NodeJS and OpenSearch

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages