Quickstart
This guide uses the REST API so you can follow along from a terminal. If your site runs WordPress, the plugin does all of this for you.
-
Create an account and an app.
Sign up at app.shoofai.co and confirm your email address. Then select New app, give it a name and pick a platform (Custom / API for this guide).
The app’s application ID is made from its name (“My Store” becomes
my-store) and never changes. You’ll see the app’s two keys once:- the search key (
shf_pub_…), which is safe to put in a web page; - the admin key (
shf_adm_…), which can change your index and must stay on your server.
- the search key (
-
Save your credentials in your shell.
Terminal window export SHOOF_APP=my-storeexport SHOOF_SEARCH_KEY=shf_pub_...export SHOOF_ADMIN_KEY=shf_adm_...export SHOOF_API=https://api.shoofai.co/v1/apps/$SHOOF_APP -
Index some records.
A record is one item in one language. Only
idis required, but atitle, some text and atypemake it worth finding.refresh=truewaits until the records are searchable, which is handy while testing.Terminal window curl -s "$SHOOF_API/records/batch?refresh=true" \-H "x-shoof-api-key: $SHOOF_ADMIN_KEY" \-H "content-type: application/json" \-d '{"upserts": [{ "id": "shoe-1", "type": "product", "lang": "en","title": "Trail running shoe", "brand": "Salomon", "price": 140,"categories": ["Shoes", "Running"],"content": "Deep lugs grip on wet rock and mud. Waterproof upper." },{ "id": "shoe-2", "type": "product", "lang": "en","title": "Road racing flat", "brand": "Asics", "price": 95,"categories": ["Shoes", "Running"],"content": "Light and fast for race day on tarmac." },{ "id": "guide-1", "type": "post", "lang": "en","title": "How to choose trail shoes","content": "Look for a grippy outsole, a protective toe cap and a waterproof membrane if you run in the rain." }]}'import { ShoofAdminClient } from "@shoof/js-client/admin";const admin = new ShoofAdminClient({ appId: "my-store", apiKey: process.env.SHOOF_ADMIN_KEY! });await admin.batch({upserts: [{ id: "shoe-1", type: "product", lang: "en", title: "Trail running shoe", brand: "Salomon", price: 140,categories: ["Shoes", "Running"], content: "Deep lugs grip on wet rock and mud. Waterproof upper." },{ id: "shoe-2", type: "product", lang: "en", title: "Road racing flat", brand: "Asics", price: 95,categories: ["Shoes", "Running"], content: "Light and fast for race day on tarmac." },{ id: "guide-1", type: "post", lang: "en", title: "How to choose trail shoes",content: "Look for a grippy outsole, a protective toe cap and a waterproof membrane if you run in the rain." },],}, { refresh: true });The response says what happened to each record:
{ "indexed": 3, "updated": 0, "skipped": 0, "deleted": 0, "embedded": 3, "errors": [] } -
Search.
Search with the search key. This query shares no words with the trail shoe’s title, but semantic search still finds it:
Terminal window curl -s "$SHOOF_API/search" \-H "x-shoof-api-key: $SHOOF_SEARCH_KEY" \-H "content-type: application/json" \-d '{ "q": "shoes for muddy hills", "facets": ["brand", "price"] }'import { ShoofClient } from "@shoof/js-client";const client = new ShoofClient({ appId: "my-store", apiKey: "shf_pub_..." });const res = await client.search({ q: "shoes for muddy hills", facets: ["brand", "price"] });console.log(res.hits.map((h) => h.title));{"hits": [{ "id": "shoe-1", "type": "product", "title": "Trail running shoe", "brand": "Salomon", "price": 140 /* … */ },{ "id": "guide-1", "type": "post", "title": "How to choose trail shoes" /* … */ }],"nbHits": 2,"facets": {"brand": [{ "value": "Salomon", "count": 1 }],"price": { "min": 140, "max": 140 }},"queryId": "f1x9…","mode": "hybrid","processingTimeMS": 41}Try a filter, and a sort:
Terminal window curl -s "$SHOOF_API/search" \-H "x-shoof-api-key: $SHOOF_SEARCH_KEY" -H "content-type: application/json" \-d '{ "q": "running shoes", "filters": { "price": { "lte": 100 } }, "sort": "price:asc" }' -
Ask a question.
Answers stream as server-sent events: first the sources, then the text as it is written.
Terminal window curl -sN "$SHOOF_API/answer" \-H "x-shoof-api-key: $SHOOF_SEARCH_KEY" -H "content-type: application/json" \-d '{ "q": "what should I look for in a trail shoe?" }'
You now have a working search index. Your searches show up in the dashboard’s Analytics page, and you can try queries against your records in its Search preview page.