Repository navigation
Write approved Commons files to the search index, behind IMAGE_INDEXING_ENABLED - #635
Open
daoudclarke wants to merge 2 commits into
Open
daoudclarke wants to merge 2 commits into
daoudclarke wants to merge 2 commits into
Conversation
…NG_ENABLED The index_images command takes up to IMAGE_INDEX_LIMIT approved files whose text the index hasn't taken (CommonsImage.indexed_text_hash != text_hash) and writes each through index_documents as an ordinary page: canonical Commons URL, caption or cleaned file name as title, description as extract, cut to the crawler's lengths, under its own terms with the crawled pages' write priority and blacklist. Files with no real text (no caption or description, or a camera/date file name) are skipped. Revoked files are never written; one revoked or changed mid-run isn't marked as taken. Off by default, and separate from IMAGE_SEARCH_ENABLED. No functional changes to the crawler. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
8000
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This was referenced Nov 11, 2026
… old A file whose name is a camera's (IMG_1234) but which has a description is now indexed, titled by the description's opening words cut at a word boundary; only a file with no caption, no description and a camera's name is skipped. Files uploaded less than IMAGE_INDEX_MIN_UPLOAD_AGE (30 days) ago are left for a later run, so Commons has time to delete spam and copyright violations before they reach the index. No functional changes to the crawler. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
From Claude:
Stack: builds on #634 (
seed-images-prod-recheck), which builds on #633. PR 6 of the #610 plan.What changed
index_imagesmanagement command (mwmbl/imagesearch/indexing.py,mwmbl/management/commands/index_images.py). It writes approved files from theCommonsImagestore to the main index as ordinary documents:https://commons.wikimedia.org/wiki/File:….IMG_1234) and there is a description, the title is the description's opening words, cut at a word boundary to the title length.NUM_TITLE_CHARS65,NUM_EXTRACT_CHARS155), the same waycrawler/app.pycuts them.index_documents, the path crawled pages take. That means they are indexed under their own terms and never under any query, with the same heuristic write priority, the same cleaning and the normal blacklist check.IMG_1234,IMG_E1234,DSC_0045,P1010001,IMG-20230101-WA0001,PXL_…~2,DSC01234-Enhanced-NR,SANY0001,20230101_123456,Screenshot 2023-01-01 at 12.34.56.P-51,747,1984andWP 40count as real text. A camera prefix needs at least 3 digits after it; a bare number needs at least 6.CommonsImage.indexed_text_hash(migration 0054) records thetext_hashlast taken, whether that file was written or skipped.indexed_text_hash != text_hash, oldest first, up toIMAGE_INDEX_LIMIT(1000).IMAGE_INDEX_MIN_UPLOAD_AGE(30 days) ago are written, against spam. A younger file isn't marked, so a later run takes it. Commons deals with copyright violations and obvious spam by speedy deletion, usually within days. Deletion requests are slower: one Phabricator analysis found about 38% closed within a week and most of the rest within a month, with a tail past three months. The recheck already revokes a file once it is nominated, so 30 days covers the fast path and nominations cover the slow one.IMAGE_INDEXING_ENABLED(env, default off) gates the command. It is separate fromIMAGE_SEARCH_ENABLED.Why a command and not the store's thread
recheck_imagesfinds, which no search ever sees.The privacy decision says image writes should not be batched or delayed. The command is chosen for the operational reasons above, not for privacy, and it batches writes only as far as the schedule does. It is easy to run often. No schedule is wired up here: switching indexing on is PR 10.
Revocation
IMAGE_INDEXING_ENABLEDbefore then.Verification
make checkpasses.make test: 1967 passed, 10 skipped.test/test_image_indexing.py(43 tests) covers:last_crawled, and the crawler's lengths.DATA_PATH/INDEX_NAME, and writes nothing while switched off.Review
One subagent did a combined code, security, trust-and-safety and holistic review.
Fixed:
WP,SAMandPprefixes as camera names. It also missedSANY,VID,IMG_E,-HDR,-Enhanced-NR,~2, and screenshot or WhatsApp names with "at".indexedcount included documents the index trimmed. It now reports stored and dropped fromindex_documents' result.Decided by the user since: a camera-named file with a description is kept and titled from the description; a 30-day minimum upload age.
Not changed, for the user to decide:
Privacy side channel. No query is stored, but the set of indexed files follows from what people searched for. A Commons file on a sensitive topic appearing in public search says that someone's search fetched it, though not who or when. This is now stated in the module docstring. The plan's privacy decision ruled out batching or delaying writes for this reason. The reviewer suggests settling it before switching on, for example by indexing a file only once Seed Search has seen it on k distinct days.
Uploader spam. An uploader controls the caption and description, which become the title and extract. The NSFW judge doesn't look for spam. What limits this:
The reviewer suggests:
DocumentSource, so these documents can be filtered or purged as a groupEviction cost. Up to 1000 low-prior documents a run compete for term pages. Measure before switching on.
Category-only edits.
text_hashcovers categories, so a category-only edit re-writes an unchanged document. This is harmless.Part of #610
🤖 Generated with Claude Code