Add operator-aware Snapshot search across ArchiveBox

Merged
PI
13h ago
+2643-225

Use the same snapshot query in the public index, admin, CLI, REST API, Smart Folder builder and existing export links. The native clients reuse the server’s search field, including its keyboard behavior and permission-scoped autocomplete. iOS PR · Android PR

ViewBeforeAfter
PublicPublic search on devTag and exact title search in the public index
AdminAdmin search on devAligned sidebar and search headers in Snapshot admin

Search and autocomplete use the current folder, tag, domain and active Django filters. Clearing the query restores that selection. Below, the tag sidebar and public-permission filter narrow a search to one snapshot. The result panel switches to compact rows when it has 900 CSS pixels or less, and shows the first tag by name.

Scoped search with solar-research and Public selected

The same expression wraps to two lines on a 1280 px desktop. On a 390 px phone the editor grows to 208 px, then scrolls vertically. The search field, count and partial-results message fit at 320 px. Metadata badges use lavender, host and link badges use teal, and quoted text keeps its blue highlight.

Long query on desktop and phone

Wrapped search at a desktop viewport

Wrapped search on a 390 px phone

Query execution. The parser preserves quoted literals, groups and aliases. The interpreter compiles database predicates with Django, using the existing domain lookup and Smart Folder field schema. It resolves as much of each Boolean branch as possible before reading content. External commands receive only authorized candidate IDs and outstanding predicates. Missing evidence stays unknown under negation. Each external search has a shared deadline and limits on directories, files and bytes.

Provider contract. Indexed plugins can return scores or provider order. File hits stream as they are confirmed. Existing third-party search commands still provide positive evidence for word queries. The new candidate and outlink capabilities are registered by the providers. This PR depends on the companion abx-plugins PR and its normal dependency release before rollout. The changes use existing tables and indexes.

Smart Folders. Search and Advanced rules intersect, retaining relationship IDs, nested rules, sort and limit. Saved folders support database-backed membership because deletion, moves and webhook diffs need definitive answers during writes. External predicates are available in ad hoc search. The form explains that boundary before saving.

Saved Smart Folder combining search and an Advanced rule

The browser checks exercised the actual public and admin HTML in light and dark modes across 32 layouts. They covered scoped completion, nested editing and submitted result membership. A phone-width regression also exercises arrows, backspace, undo, the hidden tag alias and quoted colons. The same sorted query selected the expected rows in CSV, RSS and ZIP. After another matching snapshot was added, the original RSS URL returned it.

On Cabbage, bounded read-only searches against existing artifacts confirmed both link directions in roughly 0.13 seconds across two snapshots. A three-candidate query against the configured Sonic service returned its first hit in 2.08 seconds and read zero archive bytes. A bounded deep query returned its first hit in 2.13 seconds. These timings measure small candidate sets. ORM and provider regressions also ran against SQLite and PostgreSQL 16.


Summary by cubic

Replaces the search mode dropdown with a shared operator expression field used across the public index, admin, CLI, REST API, export links, and Smart Folder builder. Filters like tags:solar, title:"Solar Panel", ~status:queued, and grouped Boolean logic now work everywhere; old modes (meta, url, contents, deep) remain available as field operators such as deep:needle. query is the new default search mode.

  • The operator tokenizer scans the editable query in a single forward pass, so an unclosed literal fails at its current offset instead of re-searching at each escaped quote.
  • The interpreter resolves predicates with Django and registered external providers, sharing one deadline and file/byte limits per query.
  • External providers can return scores, provider order, live file-hit streaming, candidate IDs, and outlink evidence; partial results and stream errors surface in the results panel.
  • Saved Smart Folders persist database-backed membership; search and Advanced rules intersect while keeping sort and limit, and external predicates only apply in ad hoc search.
  • Native mobile clients reuse the server field, including autocomplete and permissions, via /public/search-field/ and /public/search-suggestions/.

Dependencies

  • The new candidate and outlink provider capabilities require the companion abx-plugins release before rollout. SQLite and PostgreSQL 16 ORM/provider tests pass.