Index your first document
Send a document to Etoile. It becomes searchable in seconds.
Prerequisites
- An Etoile account (sign up)
- A project with a secret key (from your dashboard)
The secret key is required for write operations (index, update, delete). Do not share it publicly.
Index a painting
We are indexing one document in the paintings collection and pointing to a
URL in metadata for later use in your UI.
import { Etoile } from "@etoile-dev/client";
const etoile = new Etoile({
secretKey: process.env.ETOILE_SECRET_KEY,
});
// Index one document in the "paintings" collection.
await etoile.index({
id: "starry-night",
collection: "paintings",
title: "The Starry Night",
content: "The Starry Night is an oil-on-canvas painting by the Dutch...",
metadata: {
artist: "Vincent van Gogh",
year: "1889",
url: "/paintings/starry-night",
},
});const response = await fetch("https://etoile.dev/api/v1/index", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.ETOILE_SECRET_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
id: "starry-night",
collection: "paintings",
title: "The Starry Night",
content: "The Starry Night is an oil-on-canvas painting by the Dutch...",
metadata: {
artist: "Vincent van Gogh",
year: "1889",
url: "/paintings/starry-night",
},
}),
});
const data = await response.json();curl -X POST "https://etoile.dev/api/v1/index" \
-H "Authorization: Bearer $ETOILE_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"id": "starry-night",
"collection": "paintings",
"title": "The Starry Night",
"content": "The Starry Night is an oil-on-canvas painting by the Dutch...",
"metadata": {
"artist": "Vincent van Gogh",
"year": "1889",
"url": "/paintings/starry-night"
}
}'Response
{
"id": "starry-night",
"message": "Document indexed successfully.",
"type": "text",
"usage": 847
}Next
- Make your first search
- Index document (POST) — full API reference
- Node SDK — use the client library