exa-search
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseExa Search Integration
Exa搜索集成
Quick Reference
快速参考
| Topic | When to Use | Reference |
|---|---|---|
| Search Modes | Choosing between auto, neural, and keyword search | search-modes.md |
| Filters | Domain, date, text, and category filtering | filters.md |
| Contents | Text extraction, highlights, summaries, livecrawl | contents.md |
| SDK Patterns | Python (exa_py) and TypeScript (exa-js) usage | sdk-patterns.md |
| 主题 | 使用场景 | 参考链接 |
|---|---|---|
| 搜索模式 | 在自动、神经和关键词搜索之间做选择 | search-modes.md |
| 筛选器 | 域名、日期、文本和分类过滤 | filters.md |
| 内容获取 | 文本提取、高亮显示、摘要、实时爬取 | contents.md |
| SDK使用模式 | Python(exa_py)和TypeScript(exa-js)的用法 | sdk-patterns.md |
Essential Patterns
核心使用模式
Basic Search (Python)
基础搜索(Python)
python
from exa_py import Exa
exa = Exa(api_key="your-api-key") # or set EXA_API_KEY env var
results = exa.search_and_contents(
"latest developments in quantum computing",
type="auto",
num_results=10,
text=True,
highlights=True
)
for result in results.results:
print(f"{result.title}: {result.url}")
print(result.text[:500])python
from exa_py import Exa
exa = Exa(api_key="your-api-key") # or set EXA_API_KEY env var
results = exa.search_and_contents(
"latest developments in quantum computing",
type="auto",
num_results=10,
text=True,
highlights=True
)
for result in results.results:
print(f"{result.title}: {result.url}")
print(result.text[:500])Basic Search (TypeScript)
基础搜索(TypeScript)
typescript
import Exa from "exa-js";
const exa = new Exa(process.env.EXA_API_KEY);
const results = await exa.searchAndContents(
"latest developments in quantum computing",
{
type: "auto",
numResults: 10,
text: true,
highlights: true,
}
);
results.results.forEach((result) => {
console.log(`${result.title}: ${result.url}`);
});typescript
import Exa from "exa-js";
const exa = new Exa(process.env.EXA_API_KEY);
const results = await exa.searchAndContents(
"latest developments in quantum computing",
{
type: "auto",
numResults: 10,
text: true,
highlights: true,
}
);
results.results.forEach((result) => {
console.log(`${result.title}: ${result.url}`);
});Search with Filters
带筛选条件的搜索
python
results = exa.search_and_contents(
"AI startup funding rounds",
type="neural",
num_results=10,
include_domains=["techcrunch.com", "venturebeat.com"],
start_published_date="2024-01-01",
text={"max_characters": 2000},
summary=True
)python
results = exa.search_and_contents(
"AI startup funding rounds",
type="neural",
num_results=10,
include_domains=["techcrunch.com", "venturebeat.com"],
start_published_date="2024-01-01",
text={"max_characters": 2000},
summary=True
)Find Similar Links
查找相似链接
python
similar = exa.find_similar_and_contents(
"https://example.com/interesting-article",
num_results=10,
exclude_source_domain=True,
text=True
)python
similar = exa.find_similar_and_contents(
"https://example.com/interesting-article",
num_results=10,
exclude_source_domain=True,
text=True
)Search Mode Selection
搜索模式选择
| Mode | When to Use | Notes |
|---|---|---|
| Default for most queries | Exa optimizes between neural/keyword automatically |
| Natural language, conceptual queries | Best for "what is...", "how to...", topic exploration |
| Exact matches, technical terms, names | Best for specific product names, error codes, proper nouns |
| 模式 | 使用场景 | 说明 |
|---|---|---|
| 大多数查询的默认选择 | Exa会自动在神经/关键词搜索之间优化选择 |
| 自然语言、概念类查询 | 最适合“什么是……”“如何……”这类问题,以及主题探索 |
| 精确匹配、技术术语、名称 | 最适合特定产品名称、错误代码、专有名词 |
Common Mistakes
常见错误
- Using for conceptual queries - Neural search understands intent better; use
keywordorautofor natural language questionsneural - Not setting - Search returns URLs only by default; explicitly request content with
text=Truetext=True - Ignoring - Use
highlightsfor relevant snippets without downloading full page texthighlights=True - Missing API key - Set environment variable or pass explicitly to constructor
EXA_API_KEY - Over-filtering initially - Start with broad searches, then add domain/date filters to refine
- Not using - For RAG applications,
summaryprovides concise context without full page textsummary=True - Expecting scores in auto mode - Relevance scores are only returned with ; auto mode doesn't include them
type="neural"
- 为概念类查询使用模式 - 神经搜索更能理解意图;针对自然语言问题请使用
keyword或auto模式neural - 未设置- 默认情况下搜索仅返回URL;需显式设置
text=True来请求内容text=True - 忽略参数 - 使用
highlights可获取相关片段,无需下载完整页面文本highlights=True - 缺少API密钥 - 设置环境变量,或在构造函数中显式传入
EXA_API_KEY - 初始过滤条件过于严格 - 先从宽泛的搜索开始,再添加域名/日期筛选条件来细化结果
- 未使用参数 - 对于RAG应用,
summary可提供简洁的上下文,无需完整页面文本summary=True - 期望自动模式返回评分 - 相关性评分仅在模式下返回;自动模式不提供评分",
type="neural"