Skip to content

Add ocl index commands for ES reindexing - #8

Open
jamlung-ri wants to merge 1 commit into
mainfrom
feat/index-reindex-commands
Open

Add ocl index commands for ES reindexing#8
jamlung-ri wants to merge 1 commit into
mainfrom
feat/index-reindex-commands

Conversation

@jamlung-ri

Copy link
Copy Markdown
Member

Summary

  • Adds ocl index source concepts OWNER SOURCE and ocl index source mappings OWNER SOURCE — trigger reindexing for a source's concepts or mappings (requires source ownership, not superadmin)
  • Adds ocl index expansion concepts/mappings OWNER COLLECTION VERSION EXPANSION — reindex a collection expansion's resources (admin only)
  • Adds ocl index rebuild, ocl index populate, and ocl index resource RESOURCE — admin-level global ES index management

API endpoints covered

Command Endpoint Permission
index source concepts POST /{owner_type}/{owner}/sources/{source}/[{version}/]concepts/indexes/ Source owner
index source mappings POST /{owner_type}/{owner}/sources/{source}/[{version}/]mappings/indexes/ Source owner
index expansion concepts POST /…/expansions/{expansion}/concepts/index/ Admin
index expansion mappings POST /…/expansions/{expansion}/mappings/index/ Admin
index rebuild POST /indexes/apps/rebuild/ Admin
index populate POST /indexes/apps/populate/ Admin
index resource RESOURCE POST /indexes/resources/{resource}/ Admin

Test plan

  • ocl index source concepts WHO CIEL — triggers concept reindex, returns task ID
  • ocl index source mappings WHO CIEL --version v2025-04-03 — scoped to a version
  • ocl index source concepts WHO CIEL --single-batch --no-parallel
  • ocl index rebuild — admin token required, returns task
  • ocl index resource concepts --uri /orgs/WHO/ — admin batch reindex
  • ocl index resource concepts (no filter) — should print usage error
  • ocl index --help, ocl index source --help, ocl index expansion --help

🤖 Generated with Claude Code

Introduces `ocl index` command group covering all reindex endpoints
available in the OCL API: source-scoped concept/mapping reindex
(requires source ownership), collection expansion concept/mapping
reindex (admin only), and global ES admin operations (rebuild,
populate, batch resource reindex).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@paynejd paynejd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jamlung-ri — this is a genuinely useful addition, and I verified all seven endpoints exist and behave as the code assumes. Worth calling out one thing you got right: correctly separating the JSON endpoints (source index) from the MultiPartParser-only admin endpoints (rebuild/populate/resource) via _post_multipart() — that's easy to get wrong, and the empty-202 handling is correct too.

A few changes before it can go in:

  1. --version--repo-version on index source concepts and index source mappings. This repo uses type-specific version flags (--repo-version for sources), documented in CLAUDE.md (Conventions) and README.md: "Never use a bare --version." Please rename to match the rest of the CLI — that means the Click option, the function parameter, and the version= argument in the client call.
  2. Update README.md + docs/demos/. This adds a whole index command group but touches neither; the repo convention (also in CLAUDE.md) is to update both whenever commands/flags change, so they stay discoverable in the reference. When you do, please flag the global ops (rebuild, populate, resource) as admin-only — they're sysadmin-grade and we'd like that explicit.
  3. Add a smoke test. #10 (just merged) landed a lightweight CliRunner pattern in tests/test_concept_commands.py; even one delegation test per command group would help here, especially since these kick off expensive/destructive reindex jobs. The index resource "no --ids/--uri/--filter → error" path is a good one to lock down too.
  4. File a tracking ticket in OpenConceptLab/ocl_issues and link it. (That per-PR convention wasn't written down in this repo — on us — but we'd like the link going forward.)

The capability itself is the right shape — this is just conventions, docs, and tests before merge. Thanks for building it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants