计划执行与检查节点
executing-plans
按既定实施计划完成工作,保持过程检查和反馈。
index-search-fetch【效率与协作】Build, search, fetch, and inspect Pyserini Lucene indexes using CLI and Python APIs.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
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.
JsonCollection input, build a Lucene index with python -m pyserini.index.lucene, then search with LuceneSearcher or python -m pyserini.search.lucene.LuceneSearcher(index_path) or LuceneSearcher.from_prebuilt_index(name), then searcher.search(query, k) and searcher.doc(docid).LuceneIndexReader for stats(), terms(), get_term_counts(), get_postings_list(), get_document_vector(), get_term_positions(), and BM25 term weights.Analyzer(get_lucene_analyzer(...)), JWhiteSpaceAnalyzer for pretokenized text, and pyserini.search.lucene.querybuilder for explicit Lucene query objects.dense-encoding.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"}
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())
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.id and string contents.--storeRaw when future document fetch needs raw(), --storeDocvectors when RM3 or document vectors are needed, and --storePositions when positions are needed.docid values as strings; do not treat Lucene internal integer docids as stable identifiers.analyzer=None for already analyzed terms.--language, set_language, or JWhiteSpaceAnalyzer).