Sort by text relevance.
This only works if the query includes at least one text query, leading to a weighted result. This method raises TypeError if the result is not weighted.
A weighted result is a dictionary-ish object that has docids as keys and floating point weights as values. This method sorts the dictionary by weight and returns the sorted docids as a list.
Index for model paths (tokens separated by ‘/’ characters)
A path index stores all path components of the physical path of an object.
Internal datastructure:
Insert an entry.
comp is a path component id is the docid level is the level of the component inside the path
path is either a string representing a relative URL or a part of a relative URL or a tuple (path,level).
level >= 0 starts searching at the given level level < 0 not implemented yet
Index for model paths (tokens separated by ‘/’ characters or tuples representing a model path).
A path index may be queried to obtain all subobjects (optionally limited by depth) of a certain path.
This index differs from the original repoze.catalog.indexes.path.CatalogPath index inasmuch as it actually retains a graph representation of the objects in the path space instead of relying on ‘level’ information; query results relying on this level information may or may not be correct for any given tree. Use of this index is suggested rather than the path index.
Provided a path string (e.g. /path/to/object) or a path tuple (e.g. ('', 'path', 'to', 'object'), or a path list (e.g. ['', 'path', 'to' object'])), search the index for document ids representing subelements of the path specified by the path argument.
If the path argment is specified as a tuple or list, its first element must be the empty string. If the path argument is specified as a string, it must begin with a / character. In other words, paths passed to the search method must be absolute.
If the depth argument is specified, return only documents at this depth and below. Depth 0 will returns the empty set (or only the docid for the path specified if include_path is also True). Depth 1 will return docids related to direct subobjects of the path (plus the docid for the path specified if include_path is also True). Depth 2 will return docids related to direct subobjects and the docids of the children of those subobjects, and so on.
If include_path is False, the docid of the object specified by the path argument is not returned as part of the search results. If include_path is True, the object specified by the path argument is returned as part of the search results.
If attr_checker is not None, it must be a callback that accepts two arguments: the first argument will be the attribute value found, the second argument is a sequence of all previous attributes encountered during this search (in path order). If attr_checker returns True, traversal will continue; otherwise, traversal will cease.
A two-way map between addresses (e.g. location paths) and document ids.
The map is a persistent object meant to live in a ZODB storage.
Additionally, the map is capable of mapping ‘metadata’ to docids.
Add a new document to the document map.
address is a string or other hashable object which represents a token known by the application.
docid, if passed, must be an int. In this case, remove any previous address stored for it before mapping it to the new address. Preserve any metadata for docid in this case.
If docid is not passed, generate a new docid.
Return the integer document id mapped to address.
Add metadata related to a given document id.
data must be a mapping, such as a dictionary.
For each key/value pair in data insert a metadata key/value pair into the metadata stored for docid.
Overwrite any existing values for the keys in data, leaving values unchanged for other existing keys.
Raise a KeyError If docid doesn’t relate to an address in the document map,
Retrieve an address for a given document id.
docid is an integer document id.
Return the address corresponding to docid.
If docid doesn’t exist in the document map, return None.
Retrieve a document id for a given address.
address is a string or other hashable object which represents a token known by the application.
Return the integer document id corresponding to address.
If address doesn’t exist in the document map, return None.
Return the metadata for docid.
Return a mapping of the keys and values set using add_metadata.
Raise a KeyError If metadata does not exist for docid.
Return a new document id.
The returned value is guaranteed not to be used already in this document map.
Remove a document from the document map using an address.
address is a string or other hashable object which represents a token known by the application.
Remove any corresponding metadata for address as well.
Return a True if address existed in the map, else return False.
Remove a document from the document map for the given document ID.
docid is an integer document id.
Remove any corresponding metadata for docid as well.
Return a True if docid existed in the map, else return False.
Remove metadata related to a given document id.
If docid doesn’t exist in the metadata map, raise a KeyError.
For each key in keys, remove the metadata value for the docid related to that key.
Do not raise any error if no value exists for a given key.
If no keys are specified, remove all metadata related to the docid.