Accessing the Search Interface

Most interesting functionality of Camlistore is implemented in terms of the search interface, which is provided by Camlistore’s indexer. It visits all of the stored blobs and discovers higher-level relationships between them based on its understanding of various schemas.

Search functionality is accessed via camlistore.Connection.searcher, which is a pre-configured instance of camlistore.searchclient.SearchClient.

class camlistore.searchclient.SearchClient(http_session, base_url)[source]

Low-level interface to Camlistore indexer search operations.

The indexer component visits all blobs in the store and infers connections between them based on its knowledge of certain schema formats.

In particular, the indexer is responsible for tracking all of the modification claims for a permanode and providing its flattened attribute map for any given point in time.

However, the indexer also has special knowledge of the conventions around storage of filesystems and can thus be a more convenient interface for filesystem traversal than the raw blob interface.

Callers should not instantiate this class directly. Instead, call camlistore.connect() to obtain a camlistore.Connection object and access camlistore.Connection.searcher.

describe_blob(blobref)[source]

Request a description of a particular blob, returning a BlobDescription object.

The “description” of a blob is the indexer’s record of the blob, so it contains only the subset of information retained by the indexer. The level of detail in the returned object will thus depend on what the indexer knows about the given object.

get_claims_for_permanode(blobref)[source]

Get the claims for a particular permanode, as an iterable of ClaimMeta.

The concept of “claims” is what allows a permanode to appear mutable even though the underlying storage is immutable. The indexer processes each of the valid claims on a given permanode to produce an aggregated set of its attributes for a given point in time.

Most callers should prefer to use describe_blob() instead, since that returns the flattened result of processing all attributes, rather than requiring the client to process the claims itself.

query(expression)[source]

Run a query against the index, returning an iterable of SearchResult.

The given expression is just passed on verbatim to the underlying query interface.

Query constraints are not yet supported.

Get Blob Descriptions

One important feature of search interface is its ability to obtain the current state of a mutable object, or even its state at a particular point in time.

camlistore.searchclient.SearchClient.describe_blob() takes a blobref and returns a camlistore.searchclient.BlobDescription object that provides access to the index metadata for the given blob, as well as efficient access to descriptions of related objects.

class camlistore.searchclient.BlobDescription(searcher, raw_dict, other_raw_dicts={})[source]

Represents the indexer’s description of a blob, from SearchClient.describe_blob().

blobref[source]

The blobref of the blob being described.

describe_another(blobref)[source]

Obtain a description of another related blob.

When asked for a description, the indexer also returns descriptions of some of the objects related to the requested object, such as the files in a directory.

This interface allows callers to retrieve related objects while possibly making use of that already-retrieved data, falling back on a new call to the indexer if the requested blob was not already described.

Since this method sometimes uses data retrieved earlier, it may return stale data. If the latest data is absolutely required, prefer to call directly SearchClient.describe_blob().

size[source]

The indexer’s idea of the size of the blob.

type[source]

The indexer’s idea of the type of the blob.

Execute Search Queries

The other main capability of the search interface is querying the store to find objects fitting certain criteria.

camlistore.searchclient.SearchClient.query is the interface to this functionality, returning an iterable of camlistore.searchclient.SearchResult objects.

class camlistore.searchclient.SearchResult(blobref)[source]

Represents a search result from SearchClient.query().

blobref = None

The blobref of the blob represented by this search result.

Access Raw Permanode Claims

The mechanism by which Camlistore implements mutable objects is via permanodes which act as an immitable persistent “name” for a mutable object, and claims which describe mutations of permanodes.

Most callers will use the flattened list of permanode attributes provided by camlistore.searchclient.SearchClient.describe_blob(), but it is also possible to access the raw claim list for a permanode via camlistore.searchclient.SearchClient.get_claims_for_permanode(), which returns an iterable of camlistore.searchclient.ClaimMeta objects.

class camlistore.searchclient.ClaimMeta(raw_dict)[source]

Description of a claim.

A claim is a description of a mutation against a permanode. The indexer aggregates claims to decide the state of a permanode for a given point in time.

The type attribute represents the kind of mutation, and a different subset of the other attributes will be populated depending on that type.

attr[source]

For claims that mutate attributes, the name of the attribute that this claim mutates, as a string.

blobref[source]

The blobref of the underlying claim object.

permanode_blobref[source]

The blobref of the permanode to which this claim applies.

signer_blobref[source]

The blobref of the public key of the party that made this claim, against which the claim’s signature was verified.

target_blobref[source]

For claim types that have target blobs, the blobref of the claim’s target.

time[source]

The time at which the claim was made, as a :py:class:datetime.datetime:. The timestamps of claims are used to order them and to allow the indexer to decide the state of a permanode on any given date, by filtering later permanodes.

type[source]

The type of mutation being performed by this claim.

value[source]

For claims that mutate attributes, the value applied to the mutation.

Table Of Contents

Previous topic

Accessing the Blob Store

Next topic

Error Types

This Page