libreantdb package¶
-
class
libreantdb.
DB
(es, index_name)[source]¶ Bases:
object
This class contains every query method and every operation on the index
The following elasticsearch body response example provides the typical structure of a single document.
{ "_index" : "libreant", "_type" : "book", "_id" : "AU4RleAfD1zQdqx6OQ8Y", "_version" : 1, "found" : true, "_source": {"_language": "en", "_text_en": "marco belletti pdf file latex manual", "author": "marco belletti", "type": "pdf file", "title": "latex manual", "_attachments": [{"sha1": "dc8dc34b3e0fec2377e5cf9ea7e4780d87ff18c5", "name": "LaTeX_Wikibook.pdf", "url": "fsdb:///dc8dc34b3e0fec2377e5cf9ea7e4780d87ff18c5", "notes": "A n example bookLatex wikibook", "mime": "application/pdf", "download_count": 7, "id": "17fd3d898a834e2689340cc8aacdebb4", "size": 23909451}] } }
-
add_book
(**book)[source]¶ - Call it like this:
- db.add_book(doc_type=’book’, body={‘title’: ‘foobar’, ‘_language’: ‘it’})
-
file_is_attached
(url)[source]¶ return true if at least one book has file with the given url as attachment
-
increment_download_count
(id, attachmentID, doc_type='book')[source]¶ Increment the download counter of a specific file
-
modify_book
(id, body, doc_type='book', version=None)[source]¶ replace the entire book body
Instead of update_book this function will overwrite the book content with param body
If param version is given, it will be checked that the changes are applied upon that document version. If the document version provided is different from the one actually found, an elasticsearch.ConflictError will be raised
-
setup_db
(wait_for_ready=True)[source]¶ Create and configure index
If wait_for_ready is True, this function will block until status for self.index_name will be yellow
-
Submodules¶
-
class
libreantdb.api.
DB
(es, index_name)[source]¶ Bases:
object
This class contains every query method and every operation on the index
The following elasticsearch body response example provides the typical structure of a single document.
{ "_index" : "libreant", "_type" : "book", "_id" : "AU4RleAfD1zQdqx6OQ8Y", "_version" : 1, "found" : true, "_source": {"_language": "en", "_text_en": "marco belletti pdf file latex manual", "author": "marco belletti", "type": "pdf file", "title": "latex manual", "_attachments": [{"sha1": "dc8dc34b3e0fec2377e5cf9ea7e4780d87ff18c5", "name": "LaTeX_Wikibook.pdf", "url": "fsdb:///dc8dc34b3e0fec2377e5cf9ea7e4780d87ff18c5", "notes": "A n example bookLatex wikibook", "mime": "application/pdf", "download_count": 7, "id": "17fd3d898a834e2689340cc8aacdebb4", "size": 23909451}] } }
-
add_book
(**book)[source]¶ - Call it like this:
- db.add_book(doc_type=’book’, body={‘title’: ‘foobar’, ‘_language’: ‘it’})
-
file_is_attached
(url)[source]¶ return true if at least one book has file with the given url as attachment
-
increment_download_count
(id, attachmentID, doc_type='book')[source]¶ Increment the download counter of a specific file
-
modify_book
(id, body, doc_type='book', version=None)[source]¶ replace the entire book body
Instead of update_book this function will overwrite the book content with param body
If param version is given, it will be checked that the changes are applied upon that document version. If the document version provided is different from the one actually found, an elasticsearch.ConflictError will be raised
-
setup_db
(wait_for_ready=True)[source]¶ Create and configure index
If wait_for_ready is True, this function will block until status for self.index_name will be yellow
-