libreantdb

class libreantdb.DB(es, index_name)[source]

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’})
autocomplete(fieldname, start)[source]
delete_book(id)[source]
file_is_attached(url)[source]

return true if at least one book has file with the given url as attachment

get_all_books(size=30)[source]
get_book_by_id(id)[source]
get_books_by_actor(authorname)[source]
get_books_by_title(title)[source]
get_books_multilanguage(query)[source]
get_books_querystring(query, **kargs)[source]
get_books_simplequery(query)[source]
get_last_inserted(size=30)[source]
increment_download_count(id, attachmentID, doc_type='book')[source]

Increment the download counter of a specific file

iterate_all()[source]
mlt(_id)[source]

High-level method to do “more like this”.

Its exact implementation can vary.

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

update_book(id, body, doc_type='book')[source]

Update a book

The “body” is merged with the current one. Yes, it is NOT overwritten.

In case of concurrency conflict this function could raise elasticsearch.ConflictError

This acts like a “wrapper” that always point to the recommended function for user searching.