This document describes the integration of the common_crawl_search_engine submodule into ipfs_datasets_py, providing advanced web archiving and internet search capabilities as a fallback/redundancy system for RAG data retrieval.
The Common Crawl Search Engine integration provides fast, scalable access to Common Crawl archives without being bottlenecked by Cloudflare or other access restrictions. The system supports both local and remote deployment modes to accommodate the large Common Crawl URL indexes.
- Local/Embedded Mode - Direct package imports when submodule is available locally
- Remote MCP JSON-RPC Mode - Connect to standalone MCP server on another machine
- CLI Mode - Execute CLI commands (local or remote via SSH)
The functionality is exposed through multiple interfaces:
- Package Exports - Python API via
CommonCrawlSearchEngineclass - CLI Tools - Command-line interface via
ipfs-datasets common-crawl - MCP Server Tools - AI assistant access via MCP protocol
- Dashboard Integration - Web UI as a subdashboard
cd /path/to/ipfs_datasets_py
git submodule update --initThe submodule is located at:
ipfs_datasets_py/web_archiving/common_crawl_search_engine/
The Common Crawl Search Engine has its own dependencies. Install them:
cd ipfs_datasets_py/web_archiving/common_crawl_search_engine
pip install -e .from ipfs_datasets_py.processors.web_archiving import CommonCrawlSearchEngine
# Initialize in local mode
engine = CommonCrawlSearchEngine(mode="local")
# Check if available
if engine.is_available():
# Search for a domain
results = engine.search_domain("example.com", max_matches=100)
for result in results:
print(f"URL: {result['url']}")
print(f"Timestamp: {result['timestamp']}")
print(f"WARC: {result['warc_filename']}")
# List collections
collections = engine.list_collections()
# Get collection info
info = engine.get_collection_info("CC-MAIN-2024-10")
# Fetch WARC record
content = engine.fetch_warc_record(
warc_filename="crawl-data/...",
warc_offset=12345,
warc_length=1000
)from ipfs_datasets_py.processors.web_archiving import CommonCrawlSearchEngine
# Initialize in remote mode
engine = CommonCrawlSearchEngine(
mode="remote",
mcp_endpoint="http://ccindex-server.example.com:8787"
)
# Same API as local mode
results = engine.search_domain("example.com", max_matches=50)from ipfs_datasets_py.processors.web_archiving import CommonCrawlSearchEngine
# Initialize in CLI mode (uses ccindex CLI tool)
engine = CommonCrawlSearchEngine(mode="cli")
# Or remote CLI via SSH
engine = CommonCrawlSearchEngine(
mode="cli",
ssh_host="ccindex-server.example.com"
)
# Same API
results = engine.search_domain("example.com")# Search for a domain (local mode)
ipfs-datasets common-crawl search example.com --max-matches 50
# Search with specific collection
ipfs-datasets common-crawl search example.com --collection CC-MAIN-2024-10
# Search using remote MCP server
ipfs-datasets common-crawl search example.com \
--mode remote \
--endpoint http://ccindex-server:8787
# List collections
ipfs-datasets common-crawl collections --json
# Get collection info
ipfs-datasets common-crawl info CC-MAIN-2024-10
# Fetch WARC record
ipfs-datasets common-crawl fetch \
crawl-data/CC-MAIN-2024-10/segments/.../warc/file.warc.gz \
12345 1000
# Show configuration
ipfs-datasets common-crawl configThe Common Crawl integration is exposed via MCP tools for AI assistant access:
Available Tools:
search_common_crawl_advanced- Search Common Crawl with advanced optionsfetch_warc_record_advanced- Fetch WARC recordslist_common_crawl_collections_advanced- List available collectionsget_common_crawl_collection_info_advanced- Get collection metadata
Example Usage in MCP Client:
from ipfs_datasets_py.mcp_server.tools.web_archive_tools import (
search_common_crawl_advanced
)
result = await search_common_crawl_advanced(
domain="example.com",
max_matches=100,
collection="CC-MAIN-2024-10"
)
print(result) # Returns structured result dictThe Common Crawl dashboard can be integrated as a subdashboard:
from ipfs_datasets_py.dashboards import common_crawl_dashboard
# Create dashboard integration
integration = common_crawl_dashboard.create_dashboard_integration(
mode="embedded", # or "remote"
port=8788
)
# Start embedded dashboard
integration.start_embedded_dashboard()
# Get dashboard URL
url = integration.get_dashboard_url()
print(f"Dashboard available at: {url}")
# Get iframe config for embedding
iframe_config = integration.get_iframe_config()
# Get navigation item for main menu
nav_item = integration.get_nav_item()
# Health check
health = integration.health_check()from flask import Flask
from ipfs_datasets_py.dashboards.common_crawl_dashboard import register_dashboard_routes
app = Flask(__name__)
# Register Common Crawl dashboard routes
register_dashboard_routes(app, prefix="/subdashboard/common-crawl")
# Dashboard will be available at:
# - /subdashboard/common-crawl (main dashboard iframe)
# - /subdashboard/common-crawl/health (health check)
# - /subdashboard/common-crawl/config (configuration)The Common Crawl Search Engine uses several environment variables:
# State directory
export CCINDEX_STATE_DIR="state"
# Event logging
export CCINDEX_EVENT_LOG_PATH="state/ccindex_events.jsonl"
# Brave resolve strategy
export BRAVE_RESOLVE_STRATEGY="domain_url_join_parallel"
# Rowgroup settings
export BRAVE_RESOLVE_ROWGROUP_SLICE_MODE="auto"
export BRAVE_RESOLVE_ROWGROUP_WORKERS="8"
export BRAVE_RESOLVE_SKIP_LEGACY_SCHEMA="1"
# Index directories (optional)
export BRAVE_RESOLVE_ROWGROUP_INDEX_DIR="/path/to/collection/indexes"
export BRAVE_RESOLVE_ROWGROUP_YEAR_DIR="/path/to/year/indexes"engine = CommonCrawlSearchEngine(
mode="local",
master_db_path="/path/to/master.duckdb", # Optional
state_dir="state", # Default
rowgroup_index_dir="/path/to/indexes", # Optional
year_index_dir="/path/to/year/indexes" # Optional
)For development and small-scale use, run everything locally:
# Local mode with embedded indexes
engine = CommonCrawlSearchEngine(mode="local")For production with large URL indexes, run the MCP server on a dedicated machine:
On the index server:
# Start MCP server
ccindex-mcp-server --mode tcp --host 0.0.0.0 --port 8787
# Or start dashboard (includes MCP endpoint)
ccindex-dashboard --host 0.0.0.0 --port 8787On client machines:
# Connect via remote mode
engine = CommonCrawlSearchEngine(
mode="remote",
mcp_endpoint="http://ccindex-server.example.com:8787"
)Run the dashboard with iframe embedding:
from ipfs_datasets_py.dashboards.common_crawl_dashboard import CommonCrawlDashboardIntegration
# Remote dashboard
integration = CommonCrawlDashboardIntegration(
mode="remote",
remote_endpoint="http://ccindex-server:8787"
)
# Get iframe config for main dashboard
config = integration.get_iframe_config()Run the integration tests:
pytest tests/integration/test_common_crawl_submodule.py -vThe tests verify:
- Submodule is properly initialized
- Integration modules can be imported
- MCP tools are registered
- Dashboard integration is available
- Graceful fallback when submodule is unavailable
Error: Common Crawl Search Engine not available
Solution:
git submodule update --init
cd ipfs_datasets_py/web_archiving/common_crawl_search_engine
pip install -e .Error: request failed: ConnectionError
Solution:
- Verify server is running:
curl http://ccindex-server:8787/api/health - Check firewall rules
- Verify endpoint URL is correct
Error: ccindex: command not found
Solution:
cd ipfs_datasets_py/web_archiving/common_crawl_search_engine
pip install -e .Common Crawl URL indexes can be very large (100s of GB). For production:
- Use dedicated machines for index storage and queries
- Enable rowgroup slicing for faster domain lookups
- Use per-year indexes for time-based queries
- Configure appropriate worker counts based on CPU cores
For remote mode:
- Deploy MCP server close to indexes to minimize I/O latency
- Use connection pooling for multiple queries
- Consider batch operations for multiple domains
- Enable compression for large result sets
- Common Crawl Search Engine:
ipfs_datasets_py/web_archiving/common_crawl_search_engine/README.md - Web Archive Tools:
docs/tutorials/web_archive_tutorial.md - MCP Server:
docs/guides/mcp_server.md - Dashboard Integration:
docs/dashboards.md
For issues related to:
- Integration: Open an issue in
endomorphosis/ipfs_datasets_py - Search Engine: Open an issue in
endomorphosis/common_crawl_search_engine