Files changed (1) hide show
  1. README.md +115 -27
README.md CHANGED
@@ -14,48 +14,136 @@ Each crawl, we generate a Host Index, which aggregates information about each we
14
  information is aggregated from the Common Crawl [columnar index](https://commoncrawl.org/blog/index-to-warc-files-and-urls-in-columnar-format),
15
  [web graph](https://commoncrawl.org/web-graphs), and [raw crawler logs](https://data.commoncrawl.org).
16
 
 
17
  ## Quickstart
18
 
19
- ### Using duckdb:
 
 
 
 
20
 
21
- DuckDB can [read directly from Huggingface](https://huggingface.co/docs/hub/en/datasets-duckdb):
 
22
 
23
  ```sql
24
  $ duckdb
25
- D FROM 'hf://datasets/commoncrawl/host-index-testing-v2/data/crawl=CC-MAIN-2025-18/*.parquet' LIMIT 3;
26
- ┌─────────────────────┬─────────────┬────────────────┬────────────┬────────────────┬───┬───────────────────┬─────────────────┬───────────┬───────────────────┬─────────────────┐
27
- │ nutch_unfetched_pct │ fetch_other │ fetch_200_lote │ nutch_gone │ nutch_gone_pct │ … │ fetch_notModified │ nutch_redirPerm │ fetch_200 │ nutch_notModified │ crawl │
28
- │ int8 │ int64 │ int64 │ int64 │ int8 │ │ int64 │ int64 │ int64 │ int64 │ varchar │
29
- ├─────────────────────┼─────────────┼────────────────┼────────────┼────────────────┼───┼───────────────────┼─────────────────┼───────────┼───────────────────┼─────────────────┤
30
- │ 0 │ 0 │ 0 │ 3 │ 7 │ … │ 0 │ 0 │ 18 │ 0 │ CC-MAIN-2025-18 │
31
- │ 6 │ 0 │ 8 │ 0 │ 0 │ … │ 0 │ 0 │ 10 │ 41 │ CC-MAIN-2025-18 │
32
- │ 80 │ 0 │ 0 │ 8 │ 17 │ … │ 0 │ 0 │ 0 │ 0 │ CC-MAIN-2025-18 │
33
- ├─────────────────────┴─────────────┴────────────────┴────────────┴────────────────┴───┴───────────────────┴─────────────────┴───────────┴───────────────────┴─────────────────┤
34
- │ 3 rows 43 columns (10 shown) │
35
- └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
36
- D SELECT surt_host_name FROM 'hf://datasets/commoncrawl/host-index-testing-v2/data/crawl=CC-MAIN-2025-18/*.parquet' LIMIT 3;
37
- ┌──────────────────────┐
38
- │ surt_host_name │
39
- │ varchar │
40
- ├──────────────────────┤
41
- │ ae,ebury │
42
- │ be,echappeeduhainaut │
43
- │ au,com,echolaw │
44
- └──────────────────────┘
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  ```
46
 
47
- ### Using Hugging Face `datasets` library:
48
 
49
- "Streaming" mode (`streaming=True`) is recommended (see [the `datasets` docs](https://huggingface.co/docs/datasets/v4.4.1/en/stream)). This avoids the need to download all of the parquet files up-front.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
 
51
  ```python
52
  >>> from datasets import load_dataset
53
- >>> ds = load_dataset("commoncrawl/host-index-testing-v2", data_dir="data/crawl=CC-MAIN-2025-18", split="train", streaming=True)
54
- Resolving data files: 100%|████████████| 30/30 [00:00<00:00, 43614.95it/s]
55
  >>> print(next(iter(ds)))
56
- {'nutch_unfetched_pct': 0, 'fetch_other': 0, 'fetch_200_lote': 0, 'nutch_gone': 3, 'nutch_gone_pct': 7, 'robots_gone': 0, 'robots_5xx': 0, 'hcrank10': 3.446, 'warc_record_length_median': 32867, 'hcrank': 11908759.0, 'nutch_fetched': 42, 'nutch_notModified_pct': 0, 'robots_4xx': 0, 'nutch_redirTemp': 0, 'fetch_redirPerm': 2, 'fetch_4xx': 0, 'url_host_tld': 'ae', 'nutch_fetched_pct': 93, 'robots_notModified': 0, 'robots_other': 0, 'nutch_redirTemp_pct': 0, 'fetch_200_lote_pct': 0, 'nutch_numRecords': 45, 'robots_3xx': 0, 'robots_redirTemp': 0, 'warc_record_length_av': 31769, 'url_host_registered_domain': 'ebury.ae', 'surt_host_name': 'ae,ebury', 'nutch_redirPerm_pct': 0, 'fetch_redirTemp': 0, 'robots_200': 3, 'fetch_3xx': 0, 'fetch_5xx': 0, 'nutch_unfetched': 0, 'prank': 4.73550733982247e-09, 'fetch_gone': 0, 'prank10': 0.0, 'robots_redirPerm': 1, 'fetch_notModified': 0, 'nutch_redirPerm': 0, 'fetch_200': 18, 'nutch_notModified': 0}
57
  ```
58
 
 
 
59
  ## Use Cases
60
 
61
  ### Example questions this index can answer
 
14
  information is aggregated from the Common Crawl [columnar index](https://commoncrawl.org/blog/index-to-warc-files-and-urls-in-columnar-format),
15
  [web graph](https://commoncrawl.org/web-graphs), and [raw crawler logs](https://data.commoncrawl.org).
16
 
17
+
18
  ## Quickstart
19
 
20
+ The dataset is Hive-partitioned on `crawl` (`data/crawl=CC-MAIN-2025-18/*.parquet`). Open the whole
21
+ dataset once, then filter with `WHERE crawl = '...'`: because `crawl` is a partition key, the query
22
+ engine only reads the files for the crawls you ask for.
23
+
24
+ ### Using DuckDB
25
 
26
+ DuckDB can [read directly from Hugging Face](https://huggingface.co/docs/hub/en/datasets-duckdb).
27
+ Create a view over every crawl once per session:
28
 
29
  ```sql
30
  $ duckdb
31
+ D CREATE VIEW ccindex AS
32
+ SELECT * FROM read_parquet(
33
+ 'hf://datasets/commoncrawl/host-index-testing-v2/data/**/*.parquet',
34
+ hive_partitioning = true, -- exposes the `crawl` directory as a column
35
+ union_by_name = true -- tolerates the schema differences between some crawls
36
+ );
37
+ ```
38
+
39
+ This `CREATE VIEW` is slow (minutes, not seconds): DuckDB lists every file under `data/` through
40
+ the Hugging Face API and, because of `union_by_name`, reads the footer of each one to build the
41
+ merged schema. You pay this once per session. To make it faster, narrow the glob to the crawls you
42
+ need (e.g. `data/crawl=CC-MAIN-2025-*/*.parquet`), or drop `union_by_name` and stick to columns
43
+ that exist in every crawl.
44
+
45
+ Then run as many queries as you like against it. Always filter on `crawl`, and on
46
+ `url_host_tld` when you can — both prune the amount of data read.
47
+
48
+ Which crawls are available:
49
+
50
+ ```sql
51
+ D SELECT DISTINCT crawl FROM ccindex ORDER BY crawl;
52
+ ```
53
+
54
+ A single crawl:
55
+
56
+ ```sql
57
+ D SELECT surt_host_name, fetch_200, hcrank10
58
+ FROM ccindex
59
+ WHERE crawl = 'CC-MAIN-2025-18'
60
+ LIMIT 3;
61
+ ```
62
+
63
+ Several crawls — crawl names sort chronologically, so range comparisons work too:
64
+
65
+ ```sql
66
+ D SELECT crawl, count(*) AS hosts, sum(fetch_200) AS pages_200
67
+ FROM ccindex
68
+ WHERE crawl IN ('CC-MAIN-2025-13', 'CC-MAIN-2025-18')
69
+ GROUP BY crawl ORDER BY crawl;
70
+
71
+ D SELECT crawl, count(*) FROM ccindex
72
+ WHERE crawl >= 'CC-MAIN-2025-01'
73
+ GROUP BY crawl ORDER BY crawl;
74
  ```
75
 
76
+ The crawl history of one host, across every crawl:
77
 
78
+ ```sql
79
+ D SELECT crawl, fetch_200, fetch_3xx, fetch_4xx, fetch_redirPerm, nutch_unfetched_pct, hcrank10
80
+ FROM ccindex
81
+ WHERE url_host_tld = 'org' AND surt_host_name = 'org,commoncrawl'
82
+ ORDER BY crawl;
83
+ ```
84
+
85
+ Popular hosts in a crawl with mostly non-English content:
86
+
87
+ ```sql
88
+ D SELECT surt_host_name, hcrank10, fetch_200, fetch_200_lote_pct
89
+ FROM ccindex
90
+ WHERE crawl = 'CC-MAIN-2025-18' AND fetch_200 >= 100 AND fetch_200_lote_pct > 50
91
+ ORDER BY hcrank10 DESC
92
+ LIMIT 20;
93
+ ```
94
+
95
+ Notes:
96
+ - The view re-lists the files on every query. If you will hammer one crawl, materialize it
97
+ instead: `CREATE TABLE c2025_18 AS SELECT * FROM ccindex WHERE crawl = 'CC-MAIN-2025-18';`
98
+ - If your DuckDB does not auto-load `httpfs`, run `INSTALL httpfs; LOAD httpfs;` first.
99
+
100
+ ### Using pyarrow
101
+
102
+ `pyarrow.dataset` understands the Hive partitioning natively and pushes the `crawl` filter down to
103
+ the file listing:
104
+
105
+ ```python
106
+ import pyarrow.dataset as ds
107
+ from huggingface_hub import HfFileSystem
108
+
109
+ fs = HfFileSystem()
110
+ ccindex = ds.dataset(
111
+ "datasets/commoncrawl/host-index-testing-v2/data",
112
+ filesystem=fs, format="parquet", partitioning="hive",
113
+ )
114
+
115
+ crawl = ds.field("crawl")
116
+ tld = ds.field("url_host_tld")
117
+
118
+ # one crawl, one TLD
119
+ gov = ccindex.to_table(filter=(crawl == "CC-MAIN-2025-18") & (tld == "gov"))
120
+
121
+ # one host across all crawls
122
+ history = ccindex.to_table(
123
+ filter=(tld == "org") & (ds.field("surt_host_name") == "org,commoncrawl"),
124
+ columns=["crawl", "fetch_200", "fetch_3xx", "fetch_redirPerm", "hcrank10"],
125
+ ).sort_by("crawl")
126
+ ```
127
+
128
+ Pass `columns=` whenever you can: Parquet is columnar, so unread columns cost nothing.
129
+
130
+ ### Using the Hugging Face `datasets` library
131
+
132
+ "Streaming" mode (`streaming=True`) avoids downloading all of the parquet files up-front (see
133
+ [the `datasets` docs](https://huggingface.co/docs/datasets/v4.4.1/en/stream)). Point `data_dir`
134
+ at one crawl's partition; note that the `crawl` column comes from the directory name, so it does
135
+ not appear in rows loaded this way.
136
 
137
  ```python
138
  >>> from datasets import load_dataset
139
+ >>> ds = load_dataset("commoncrawl/host-index-testing-v2",
140
+ ... data_dir="data/crawl=CC-MAIN-2025-18", split="train", streaming=True)
141
  >>> print(next(iter(ds)))
142
+ {'nutch_unfetched_pct': 0, 'fetch_other': 0, ...}
143
  ```
144
 
145
+ For multi-crawl work, prefer DuckDB or pyarrow above.
146
+
147
  ## Use Cases
148
 
149
  ### Example questions this index can answer