Quickstart
Search 10,000 Wikipedia articles in Lite, then optionally move to Cloud or add local AI
- Bash and curl for downloading the sample data
Load 10,000 Wikipedia articles into a local .aflite database and search them by
keyword with the Antfly CLI. No model download or Cloud account is required.
After that, you can move the database to Cloud or
continue with the optional AI steps on this page.
Install Antfly
Download Antfly v0.3.2
for your OS and architecture, verify its published checksum, and extract the
archive. Keep its supporting files beside the binary and add that directory to
PATH. See Downloads for installation options.
antfly --version
This walkthrough uses 0.3.2. Check file compatibility before opening an existing
Lite database with another runtime version.
Start Antfly
In a new directory, start Antfly with Lite storage:
mkdir antfly-quickstart
cd antfly-quickstart
antfly standalone --storage-engine lite --storage-path "$PWD/quickstart.aflite"
Leave this terminal running. The API and dashboard are at
http://127.0.0.1:8080, and fsync is enabled by default.
--storage-path selects the database file. Other server state uses ~/.antfly;
add --data-dir "$PWD/state" if you want a separate server-state directory.
Create a Table
Open a second terminal in the same directory. The CLI defaults to the local server; clear any Cloud connection settings from an earlier session:
unset ANTFLY_URL ANTFLY_TOKEN ANTFLY_USERNAME ANTFLY_PASSWORD
unset ANTFLY_DATABASE ANTFLY_NAMESPACE
antfly table create --table wikipedia
Every table has a full-text index, full_text_index_v0. No embedding index is
needed for the first query. The SDKs use the same query API.
Download Sample Data
curl --fail --location --output wiki-articles.jsonl \
https://cdn.antfly.io/datasets/wiki-articles-10k-v001.json
The download is about 12 MB, with one JSON document per line: title, body,
and url. Of these articles, 2,446 of the 10,000 also have thumbnail_url.
The keyword steps do not download images or models.
Load Data
antfly load --table wikipedia \
--file wiki-articles.jsonl \
--id-field title \
--sync-level full_text
Wait for the load to finish successfully with 10,000 documents. The CLI batches
the writes; --sync-level full_text waits for keyword-search visibility. Titles
become stable IDs; loading again replaces documents with the same IDs.
Search
Full-Text Search
Find articles mentioning Korea:
antfly query --table wikipedia \
--full-text-search 'body:"Korea"' \
--fields "title,url" \
--limit 5
The results include article titles and source links. For scripts, use
antfly --output json query ... to get the complete JSON payload without the
agent envelope. Try another word or phrase, or continue to Cloud or local AI below.
Move this database to Cloud
Follow Move a database to Antfly Cloud to take a
consistent .aflite snapshot, upload it, and run the same CLI query against the
managed copy. Import creates a new database; it does not require reloading
Wikipedia. Your local copy remains independent.
Optional local AI
The remaining steps add embeddings, semantic and image search, reranking, and RAG to the same local table. They are optional and can take 45–90 minutes, mainly for model downloads and background indexing. Their model and memory requirements are separate from the managed Cloud Lite package.
If you followed the migration guide, reconnect the CLI to your local server:
unset ANTFLY_URL ANTFLY_TOKEN
For the all-local RAG example, stop the server with Ctrl+C, then restart the same file with an 8 GiB inference budget and a captured log:
antfly standalone --storage-engine lite --storage-path "$PWD/quickstart.aflite" \
--inference-host-budget-mb 8192 2>&1 | tee antfly.log
If you chose a separate --data-dir earlier, use the same path when restarting.
Skip the larger budget if you plan to use a hosted generator. In the second
terminal, continue with the model and index setup.
Install the text embedding model
antfly inference pull hf:google/embeddinggemma-2:bf16-safetensors-bundle-v1
antfly inference list
EmbeddingGemma2 embeds text, images, audio, and video in the same 768-dimensional space and runs on CPU, Metal, or CUDA. The running process picks up the new model on its next model-list or inference request.
Add text embeddings
Add an index to the table you already loaded:
antfly index create --table wikipedia \
--index title_body \
--type embeddings \
--coverage-policy partial \
--template '{{#if (scrubHtml title)}}{{#if (scrubHtml body)}}{{title}} {{body}}{{/if}}{{/if}}' \
--embedder '{"provider":"antfly","model":"google/embeddinggemma-2:bf16-safetensors-bundle-v1"}' \
--chunker '{"provider":"antfly","text":{"target_tokens":200,"overlap_tokens":25}}'
Antfly backfills the existing articles. The text template emits content only when both the title and body have text. Articles skipped by this index still remain in the table and can be indexed by thumbnail. Wait until 10% of source documents have searchable embeddings:
antfly index wait --table wikipedia \
--index title_body \
--until source-covered=10% \
--timeout 45m
Index artifact counts are per chunk, so they can exceed the article count. Coverage continues growing while you try the following searches.
Semantic Search
Find articles semantically similar to a natural language query:
antfly query --table wikipedia \
--semantic-search "anatomy and physiology" \
--indexes "title_body" \
--fields "title,url" \
--limit 5
Hybrid Search & Reranking
One query can run the keyword and semantic searches together; Antfly fuses the two ranked lists with Reciprocal Rank Fusion. The Qwen3 text reranker then rescores each query-document pair to improve the ordering of those candidates.
Pull the reranker model:
antfly inference pull hf:ggml-org/Qwen3-Reranker-0.6B-Q8_0-GGUF:gguf:Q8_0 --tasks rerank
The first query loads the model, so it can take tens of seconds.
antfly query --table wikipedia \
--full-text-search 'body:Einstein' \
--semantic-search "theory of relativity and physics" \
--indexes "title_body" \
--fields "title,url" \
--limit 10 \
--reranker '{
"provider": "antfly",
"model": "ggml-org/Qwen3-Reranker-0.6B-Q8_0-GGUF:gguf:Q8_0",
"field": "body"
}' \
--pruner '{"min_score_ratio": 0.01}'
Reranking changes the order and keeps the count. Pruning changes the count: min_score_ratio keeps only results scoring at least that fraction of the top result, and max_score_gap_percent stops at the first sharp drop. Tune Hybrid Search covers both in depth.
Image Search
EmbeddingGemma2 places text and images in one embedding space, so you can describe a picture in words and get the articles whose thumbnails match.
Add an image index to your table
Add a second index with the same EmbeddingGemma2 model, this time embedding each article's thumbnail:
antfly index create --table wikipedia \
--index thumbnail \
--type embeddings \
--coverage-policy partial \
--template "{{#if thumbnail_url}}{{remoteMedia url=thumbnail_url}}{{/if}}" \
--embedder '{"provider": "antfly", "model": "google/embeddinggemma-2:bf16-safetensors-bundle-v1"}' \
--distance-metric cosine
Articles without thumbnails are skipped. Wait for 250 searchable images:
antfly index wait --table wikipedia \
--index thumbnail \
--until searchable-artifacts=250 \
--timeout 45m
Search by visual content
Describe what you want to see:
antfly query --table wikipedia \
--semantic-search "map of a country" \
--indexes "thumbnail" \
--fields "title,url,thumbnail_url" \
--limit 5
Concrete visual descriptions ("red sports car", "mountain landscape") work better than abstract ones. The same pipeline enriches your own documents: PDFs and scans are read with OCR (LightOnOCR-3 locally, or a connected provider), and audio is transcribed before indexing. See Index PDFs and Scanned Documents and Index Recorded Calls and Podcasts.
RAG (Retrieval-Augmented Generation)
The retrieval agent plans the query, runs the search, and hands the results to a local language model to write the answer.
Pull a generation model
antfly inference pull hf:google/gemma-4-E2B-it-qat-q4_0-gguf:gguf \
--tasks generate \
--projector auto
--projector auto includes image and audio input; --projector none is a smaller, text-only download. To use a hosted model instead, skip to RAG with alternative providers.
Build a query and generate an answer
Give Gemma an intent and a table. The retrieval agent delegates query planning to the query builder, searches, and answers from the results.
antfly agents retrieval --table wikipedia \
--intent "How do scientists monitor volcanoes for signs of an eruption?" \
--fields "title,body" \
--limit 5 \
--generator '{
"provider": "antfly",
"model": "google/gemma-4-E2B-it-qat-q4_0-gguf",
"max_tokens": 512
}' \
--max-internal-iterations 8 \
--streaming
The command streams Server-Sent Events as each step completes and ends with event: done. Use --no-streaming to get one JSON body with the answer and its sources. To see the query the agent would run without running it, use antfly agents query-builder with the same --table, --intent, and --generator.
RAG with alternative providers
The same request runs against a hosted model or Ollama by changing the generator:
Requires a Google AI API key, exported in the terminal that runs antfly standalone (restart it after exporting):
export GEMINI_API_KEY="your-api-key-here"
antfly agents retrieval --table wikipedia \
--semantic-search "How do scientists monitor volcanoes for signs of an eruption?" \
--indexes "title_body" \
--fields "title,body" \
--limit 5 \
--generator '{"provider": "gemini", "model": "gemini-2.5-flash"}' \
--max-context-tokens 2048 \
--generate
Local models need no key and keep data on the machine; hosted ones are faster on a laptop without a GPU. Anthropic, Vertex, Bedrock, OpenRouter, and Cloudflare work the same way.
Evaluation
The retrieval API also supports quality evaluation. See the API reference when you need retrieval or generation scores in your application.
Troubleshooting
- Wrong runtime or command not found: check
antfly --versionand the extracted binary's location onPATH. Keep the archive's supporting files beside it. - Port conflict: choose another
--portand, if needed,--health-port. SetANTFLY_URLto the matching server base URL in the CLI terminal. - Table already exists: skip creation when continuing this example, or use a
fresh directory and
.aflitepath. Do not overwrite a database you want to keep. - Legacy server state: use a fresh
--data-dirand preserve the old directory. - Model not found: run
antfly inference listand inspect thestandalone inference pathsline inantfly.log. Confirm that the server and CLI use the same model directory. - Index wait timed out: capture
antfly index list --table wikipedia --output jsonand the recent server log. Counts that keep growing on unchanged data or coverage that never advances need investigation. - Memory errors: stop other large local models, use a hosted generator, or
increase
--inference-host-budget-mbif your machine has capacity.
Stop the server with Ctrl+C. The .aflite file remains on disk.
Stopping this local process does not delete a managed Cloud copy or stop its billing.
Give Your Agent the Antfly Skill
Everything you just did by hand, a coding agent can do for you. The Antfly skill carries verified, current knowledge of Antfly's APIs, query shapes, React components, and operations, for Claude Code, Cursor, Codex, and other agent harnesses:
npx skills add antflydb/antfly-skills
From here your agent can create tables, build indexes, and write queries against the instance you just started.
Next Steps
- Move a database to Antfly Cloud: snapshot, import, and verify the managed copy.
You have a running instance, an indexed table, and an agent that knows Antfly. Each of these guides builds one thing on top of that and ends with a prompt you can hand to the agent:
- Build a Support Answer Agent: one call that answers a customer's question from your help articles
- Add Search and AI Answers to Your Site: a React search page with facets and a streaming answer box
- Use Antfly from n8n: an n8n agent that answers from your table over hosted MCP
- Route Tickets with Retrieval: tickets stream out of Postgres and get a team from the resolved ones that look like them
- Power a Coding Copilot's Retrieval: a repo index that answers symbol lookups and intent questions, sized to a context budget
- Tune Hybrid Search: fusion, reranking, and pruning, and which of them your data needs
- Multimodal Embeddings: the image index from this page in depth, plus audio and your own vectors
See Deployment options for ways to run Antfly and backup and restore to protect what you loaded.