Skip to content

libzim.search

libzim search module

  • Query to prepare a query from a string
  • Searcher to perform a search over a libzim.reader.Archive

Usage:

archive = libzim.reader.Archive(fpath)
searcher = Searcher(archive)
query = Query().set_query("foo")
search = searcher.search(query)
for path in search.getResults(10, 10) # get result from 10 to 20 (10 results)
    print(path, archive.get_entry_by_path(path).title)

Classes:

  • Query

    ZIM agnostic Query-builder to use with a Searcher.

  • Search

    Search request over a ZIM Archive.

  • SearchResultSet

    Iterator over a Search result: entry paths.

  • Searcher

    ZIM Archive Searcher.

Query

ZIM agnostic Query-builder to use with a Searcher.

Methods:

  • set_query

    Set the textual query of the Query.

set_query method descriptor

set_query(query: str) -> Query

Set the textual query of the Query.

Parameters:

  • query (str) –

    The string to search for.

Returns:

  • Query

    The Query instance with updated search query.

Search

Search request over a ZIM Archive.

Methods:

  • getEstimatedMatches

    Estimated number of results in Archive for the search.

  • getResults

    Iterator over Entry paths found in Archive for the search.

getEstimatedMatches method descriptor

getEstimatedMatches() -> int

Estimated number of results in Archive for the search.

Returns:

  • int

    The number of estimeated results for this search.

getResults method descriptor

getResults(start: int, count: int) -> SearchResultSet

Iterator over Entry paths found in Archive for the search.

Parameters:

  • start (int) –

    The beginning of the range to get (offset of the first result).

  • count (int) –

    The number of results to return.

Returns:

SearchResultSet

Iterator over a Search result: entry paths.

Searcher

ZIM Archive Searcher.

Parameters:

  • archive (Archive) –

    ZIM Archive to search.

Attributes:

  • *c_searcher (Searcher) –

    a pointer to a C++ Searcher object.

Methods:

  • search

    Create a Search object for a query of this Searcher's ZIM Archive.

search method descriptor

search(query: Query) -> Search

Create a Search object for a query of this Searcher's ZIM Archive.

Returns:

  • Search

    A Search object for querying this Searcher's ZIM Archive.