AGENT SKILL

index-search-fetch

Build, search, fetch, and inspect Pyserini Lucene indexes using CLI and Python APIs.

License 许可
Apache-2.0
最近更新
2026-09-03
Stars
★ 351
Forks
27

01 前言 Front Matter

name
index-search-fetch
license
Apache 2.0
metadata
{ "disco-role": "operating" }
description
Build, search, fetch, and inspect Pyserini Lucene indexes using CLI and Python APIs.
disable-model-invocation
true

02 资源文件 6

03 SKILL.md 正文

Index, Search, and Fetch with Pyserini Lucene

Use this sub-skill when the user wants to build a BM25/Lucene index, index JSON or JSONL documents, search a custom or prebuilt Lucene index, fetch raw documents, inspect terms or term vectors, configure analyzers, or construct Lucene queries by hand.

Do not use this sub-skill for Faiss indexing/search, encoder model selection, GPU embedding pipelines, evaluation metrics, run fusion, REST servers, or MCP servers. Route those to the sibling dense-encoding, evaluation-and-fusion, or serving-and-agent-tools sub-skills. If the failure is an import, Java, JVM, Anserini fatjar, or optional dependency problem, route first to install-and-runtime.

Quick Routing

  • Custom sparse indexing: Validate JsonCollection input, build a Lucene index with python -m pyserini.index.lucene, then search with LuceneSearcher or python -m pyserini.search.lucene.
  • Search and fetch: Use LuceneSearcher(index_path) or LuceneSearcher.from_prebuilt_index(name), then searcher.search(query, k) and searcher.doc(docid).
  • Index introspection: Use LuceneIndexReader for stats(), terms(), get_term_counts(), get_postings_list(), get_document_vector(), get_term_positions(), and BM25 term weights.
  • Analysis and query construction: Use Analyzer(get_lucene_analyzer(...)), JWhiteSpaceAnalyzer for pretokenized text, and pyserini.search.lucene.querybuilder for explicit Lucene query objects.
  • Lucene dense or impact search: Keep Lucene HNSW/impact search here, but route dense vector creation, Faiss, encoder downloads, OpenAI, and GPU model issues to dense-encoding.

Default Tiny Pipeline

  1. Put documents in JsonCollection form, one object per line when using JSONL:

    {"id": "doc1", "contents": "city buses run on time"}
    {"id": "doc2", "contents": "information retrieval with lucene"}
    
  2. Validate before indexing:

    python scripts/validate_jsonl_collection.py corpus.jsonl --format jsonl --require-unique-ids
    
  3. Build an indexing command without running Java-backed indexing yet:

    python scripts/lucene_cli_builder.py index --input corpus_dir --index indexes/demo --store-raw --store-positions --store-docvectors
    
  4. Run the printed command in an environment where Pyserini and Java are working.

  5. Search and fetch:

    from pyserini.search.lucene import LuceneSearcher
    
    searcher = LuceneSearcher('indexes/demo')
    searcher.set_bm25(k1=0.9, b=0.4)
    hits = searcher.search('information retrieval', k=10)
    doc = searcher.doc(hits[0].docid)
    print(doc.raw() or doc.contents())
    

What to Read Next

  • references/data-formats.md for JsonCollection, topics, run output, stored field, and docid conventions.
  • references/lucene-workflows.md for complete indexing, BM25, RM3, QLD, impact, HNSW, fetch, and language workflows.
  • references/api-reference.md for source-grounded Python API signatures and common method combinations.
  • references/troubleshooting.md for invalid JSONL, wrong generators, missing stored raw text, analyzed-term bugs, and Java/fatjar routing.
  • scripts/validate_jsonl_collection.py --help to validate collections safely without starting Java.
  • scripts/lucene_cli_builder.py --help to generate reproducible index/search/fetch commands without executing them.

Acceptance Checklist

  • Validate custom input before indexing; each document needs a string id and string contents.
  • Add --storeRaw when future document fetch needs raw(), --storeDocvectors when RM3 or document vectors are needed, and --storePositions when positions are needed.
  • Keep external collection docid values as strings; do not treat Lucene internal integer docids as stable identifiers.
  • Decide whether terms are analyzed or unanalyzed before calling index-reader methods; pass analyzer=None for already analyzed terms.
  • For non-English or pretokenized collections, use matching indexing and search analyzers (--language, set_language, or JWhiteSpaceAnalyzer).

04 同仓库更多 Skills

VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-triton-opt

Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-solve

END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-skill

PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-pattern-fusion

Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-orchestrate

Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-feedback

Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).

★ 351