Search Examples

This page provides quick examples to get you started with Airweave search. For a comprehensive, hands-on tutorial with visualizations and real-world scenarios, check out our interactive Jupyter notebook.

Interactive Tutorial

Learn search concepts through hands-on examples in our comprehensive Jupyter notebook with live code, visualizations, and real-world scenarios.

View the Advanced Search Tutorial →

Quick Start

1from airweave import AirweaveSDK
2from airweave.schemas.search import SearchRequest
3from qdrant_client.http.models import Filter, FieldCondition, MatchValue
4
5client = AirweaveSDK(api_key="your-api-key")

Essential Examples

1# Simple text search
2response = await client.collections.search_collection(
3 readable_id="your-collection-id",
4 query="customer onboarding process"
5)

Search with AI Completion

1# Get AI-generated insights
2response = await client.collections.search_collection(
3 readable_id="your-collection-id",
4 query="What are our security policies?",
5 response_type="completion"
6)
1# Search within specific source (⚠️ case-sensitive!)
2request = SearchRequest(
3 query="API documentation",
4 filter=Filter(
5 must=[
6 FieldCondition(
7 key="source_name",
8 match=MatchValue(value="GitHub") # Must match exactly
9 )
10 ]
11 )
12)
13
14response = await client.collections.search_collection_advanced(
15 readable_id="your-collection-id",
16 search_request=request
17)

Date Range Filter

1from datetime import datetime, timezone, timedelta
2from qdrant_client.http.models import DatetimeRange
3
4# Find items from last 7 days
5request = SearchRequest(
6 query="bug fixes",
7 filter=Filter(
8 must=[
9 FieldCondition(
10 key="created_at",
11 range=DatetimeRange(
12 gte=datetime.now(timezone.utc) - timedelta(days=7)
13 )
14 )
15 ]
16 )
17)

Case-Insensitive Source Matching

1from qdrant_client.http.models import MatchAny
2
3# Handle different case variations
4request = SearchRequest(
5 query="deployment guide",
6 filter=Filter(
7 must=[
8 FieldCondition(
9 key="source_name",
10 match=MatchAny(any=["GitHub", "github", "GITHUB"])
11 )
12 ]
13 )
14)

REST API

Try the advanced search endpoint with filters in our interactive API playground. Open API Explorer →

$# GET - Basic search
>curl -X GET "https://api.airweave.ai/api/v1/collections/{id}/search?query=test" \
> -H "x-api-key: your-api-key"
>
># POST - Advanced search with filters
>curl -X POST "https://api.airweave.ai/api/v1/collections/{id}/search" \
> -H "x-api-key: your-api-key" \
> -H "Content-Type: application/json" \
> -d '{
> "query": "security vulnerabilities",
> "filter": {
> "must": [{
> "key": "source_name",
> "match": {"value": "GitHub"}
> }]
> },
> "score_threshold": 0.7
> }'

Filter Patterns

This is a hypothetical example of what you might want to do.

1# Multi-source search
2FieldCondition(
3 key="source_name",
4 match=MatchAny(any=["Asana", "Jira", "Linear"])
5)
6
7# Priority filtering
8FieldCondition(
9 key="metadata.priority",
10 match=MatchAny(any=["high", "critical", "P0"])
11)
12
13# Exclude resolved items
14Filter(
15 must_not=[
16 FieldCondition(
17 key="metadata.status",
18 match=MatchAny(any=["closed", "resolved", "done"])
19 )
20 ]
21)

Learn More