Skip to content

Quick Start Guide

1. Create Your First Collection

Let's create a collection for storing product data:

bash
curl -X PUT "http://localhost:9000/collections" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "products",
    "fields": {
      "name": {
        "type": "Text",
        "index": true,
        "stored": true,
        "facet": false
      },
      "description": {
        "type": "Text",
        "index": true,
        "stored": true,
        "facet": false
      },
      "price": {
        "type": "F64",
        "index": true,
        "stored": true,
        "facet": true
      },
      "category": {
        "type": "Keyword",
        "index": true,
        "stored": true,
        "facet": true
      },
      "in_stock": {
        "type": "Bool",
        "index": true,
        "stored": true,
        "facet": true
      }
    },
    "default_search_field": "name"
  }'

Response:

json
{
  "result": {
    "num_docs": 0,
    "created": "2024-04-10T10:00:00Z",
    "collection": {
      "name": "products",
      "fields": {...},
      "default_search_field": "name"
    }
  },
  "status": "ok",
  "time": 0.015
}

2. Index Documents

Single Document

bash
curl -X PUT "http://localhost:9000/documents/products" \
  -H "Content-Type: application/json" \
  -d '{
  "id": "1",
    "name": "Wireless Headphones",
    "description": "Bluetooth 5.0 over-ear headphones with noise cancellation",
    "price": 99.99,
    "category": "Electronics",
    "in_stock": true
  }'

Bulk Indexing

bash
curl -X PUT "http://localhost:9000/documents/jsonl/products" \
  -H "Content-Type: application/json" \
  -d $'{"name": "Wireless Headphones", "price": 99.99, "category": "Electronics", "in_stock": true}\n{"name": "Coffee Maker", "price": 49.99, "category": "Appliances", "in_stock": true}\n{"name": "Running Shoes", "price": 79.99, "category": "Sports", "in_stock": false}'

3. Search Documents

bash
curl -X GET "http://localhost:9000/search?collection=products&q=wireless"

Advanced Search with Filters and Facets

bash
curl -X POST "http://localhost:9000/search/products" \
  -H "Content-Type: application/json" \
  -d '{
    "q": "wireless",
    "limit": 10,
    "filter": {
      "category": ["Electronics"],
      "in_stock": [true]
    },
    "facets": [
      {
        "term": {
          "field": "category",
          "size": 5
        }
      },
      {
        "range": {
          "field": "price",
          "ranges": [
            {"from": 0, "to": 50},
            {"from": 50, "to": 100},
            {"from": 100}
          ]
        }
      }
    ]
  }'