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
- 参考文档references/api-reference.md6.3 KB
- 参考文档references/data-formats.md3.5 KB
- 参考文档references/lucene-workflows.md7.1 KB
- 参考文档references/troubleshooting.md5.5 KB
- 脚本scripts/lucene_cli_builder.py7.9 KB
- 脚本scripts/validate_jsonl_collection.py5.5 KB
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
JsonCollectioninput, build a Lucene index withpython -m pyserini.index.lucene, then search withLuceneSearcherorpython -m pyserini.search.lucene. - Search and fetch: Use
LuceneSearcher(index_path)orLuceneSearcher.from_prebuilt_index(name), thensearcher.search(query, k)andsearcher.doc(docid). - Index introspection: Use
LuceneIndexReaderforstats(),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(...)),JWhiteSpaceAnalyzerfor pretokenized text, andpyserini.search.lucene.querybuilderfor 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
-
Put documents in
JsonCollectionform, one object per line when using JSONL:{"id": "doc1", "contents": "city buses run on time"} {"id": "doc2", "contents": "information retrieval with lucene"} -
Validate before indexing:
python scripts/validate_jsonl_collection.py corpus.jsonl --format jsonl --require-unique-ids -
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 -
Run the printed command in an environment where Pyserini and Java are working.
-
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.mdforJsonCollection, topics, run output, stored field, and docid conventions.references/lucene-workflows.mdfor complete indexing, BM25, RM3, QLD, impact, HNSW, fetch, and language workflows.references/api-reference.mdfor source-grounded Python API signatures and common method combinations.references/troubleshooting.mdfor invalid JSONL, wrong generators, missing stored raw text, analyzed-term bugs, and Java/fatjar routing.scripts/validate_jsonl_collection.py --helpto validate collections safely without starting Java.scripts/lucene_cli_builder.py --helpto generate reproducible index/search/fetch commands without executing them.
Acceptance Checklist
- Validate custom input before indexing; each document needs a string
idand stringcontents. - Add
--storeRawwhen future document fetch needsraw(),--storeDocvectorswhen RM3 or document vectors are needed, and--storePositionswhen positions are needed. - Keep external collection
docidvalues 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=Nonefor already analyzed terms. - For non-English or pretokenized collections, use matching indexing and search analyzers (
--language,set_language, orJWhiteSpaceAnalyzer).
04 同仓库更多 Skills
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.
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.
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.
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.
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.
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).