full-text.md
72 lines · skills/pyzotero/references/full-text.md at 5f2bc03
Full-Text Content
Pyzotero can retrieve and set full-text index content for attachment items.
Raw lines 1 to 4Retrieving Full-Text Content
# Get full-text content for a specific attachment item
data = zot.fulltext_item('ATTACHMENTKEY')
# Returns:
# {
# "content": "Full text of the document...",
# "indexedPages": 50,
# "totalPages": 50
# }
# For text docs: indexedChars/totalChars instead of pages
text = data['content']
unit = 'Pages' if 'totalPages' in data else 'Chars'
total = data.get('total' + unit, 0)
coverage = data.get('indexed' + unit, 0) / total if total else NoneRaw lines 5 to 23Finding Items with New Full-Text Content
# Get item keys with full-text updated since a library version
new_fulltext = zot.new_fulltext(since=1085)
# Returns dict: {'KEY1': 1090, 'KEY2': 1095, ...}
# Values are the library version at which full-text was indexedRaw lines 24 to 32Setting Full-Text Content
# Set full-text for a PDF attachment
payload = {
'content': 'The full text content of the document.',
'indexedPages': 50,
'totalPages': 50
}
zot.set_fulltext('ATTACHMENTKEY', payload)
# For text documents use indexedChars/totalChars
payload = {
'content': 'Full text here.',
'indexedChars': len('Full text here.'),
'totalChars': len('Full text here.')
}
zot.set_fulltext('ATTACHMENTKEY', payload)Raw lines 33 to 52Full-Text Search via CLI
The CLI provides full-text search across locally indexed PDFs:
# Search full-text content
pyzotero search -q "CRISPR gene editing" --fulltext
# Output as JSON (retrieves parent bibliographic items for attachments)
pyzotero search -q "climate tipping points" --fulltext --jsonRaw lines 53 to 64Search in API (qmode=everything)
# Search in titles/creators + full-text content
results = zot.items(q='protein folding', qmode='everything', limit=20)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.