跳到主要内容

Zotero 文献库

收藏0

用 pyzotero 程序化管理 Zotero 文献库:检索条目、新建与更新条目、整理分类与标签、导出引用格式、上传 PDF 附件,支持 Web API 与本地 API。

让 AI 安装

星光尘缘LV2最新版本 0.1.0更新于 2026-11-24下载 0 次

references/full-text.md

2.4 KB查看排版效果
1# Full-Text Content
2
3Pyzotero can retrieve and set full-text index content for attachment items.
4
5## Retrieving Full-Text Content
6
7```python
8# Get full-text content for a specific attachment item
9data = zot.fulltext_item('ATTACHMENTKEY')
10# Returns:
11# {
12# "content": "Full text of the document...",
13# "indexedPages": 50,
14# "totalPages": 50
15# }
16# For text docs: indexedChars/totalChars instead of pages
17
18text = data['content']
19unit = 'Pages' if 'totalPages' in data else 'Chars'
20total = data.get('total' + unit, 0)
21coverage = data.get('indexed' + unit, 0) / total if total else None
22```
23
24## Finding Items with New Full-Text Content
25
26```python
27# Get item keys with full-text updated since a library version
28new_fulltext = zot.new_fulltext(since=1085)
29# Returns dict: {'KEY1': 1090, 'KEY2': 1095, ...}
30# Values are the library version at which full-text was indexed
31```
32
33## Setting Full-Text Content
34
35```python
36# Set full-text for a PDF attachment
37payload = {
38 'content': 'The full text content of the document.',
39 'indexedPages': 50,
40 'totalPages': 50
41}
42zot.set_fulltext('ATTACHMENTKEY', payload)
43
44# For text documents use indexedChars/totalChars
45payload = {
46 'content': 'Full text here.',
47 'indexedChars': len('Full text here.'),
48 'totalChars': len('Full text here.')
49}
50zot.set_fulltext('ATTACHMENTKEY', payload)
51```
52
53## Full-Text Search via CLI
54
55The CLI provides full-text search across locally indexed PDFs:
56
57```bash
58# Search full-text content
59pyzotero search -q "CRISPR gene editing" --fulltext
60
61# Output as JSON (retrieves parent bibliographic items for attachments)
62pyzotero search -q "climate tipping points" --fulltext --json
63```
64
65## Search in API (qmode=everything)
66
67```python
68# Search in titles/creators + full-text content
69results = zot.items(q='protein folding', qmode='everything', limit=20)
70```
71
72`fulltext_item()` sends GET to `/items/{attachmentKey}/fulltext`; a 404 can mean missing indexed content as well as a missing item. `new_fulltext()` uses `/fulltext?since=<version>` and returns a key-to-version dict. `set_fulltext()` PUTs the supplied index and returns Boolean success; it does not extract text from a PDF. Supply the actual extracted content and coverage, not guessed counts. Remote search sees synced indexed content; local search sees the local index and can differ. Keep local server versions separate from Web API versions. [Official full-text contract](https://www.zotero.org/support/dev/web_api/v3/fulltext_content).

文件内容是平台检查时读出的文本,只供查看。平台不会运行包里的任何脚本或程序。