Home | Trees | Indices | Help |
|
---|
|
object --+ | IndexerConnection
Instance Methods | |||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
Inherited from |
Class Variables | |
FacetQueryType_Preferred = 1
|
|
FacetQueryType_Never = 2
|
Properties | |
Inherited from |
Method Details |
Create a new connection to the index. There may only be one indexer connection for a particular database open at a given time. Therefore, if a connection to the database is already open, this will raise a xapian.DatabaseLockError. If the database doesn't already exist, it will be created.
|
Set the maximum memory to use. This call allows the amount of memory to use to buffer changes to be set. This will affect the speed of indexing, but should not result in other changes to the indexing. Note: this is an approximate measure - the actual amount of memory used max exceed the specified amount. Also, note that future versions of xapian are likely to implement this differently, so this setting may be entirely ignored. The absolute amount of memory to use (in bytes) may be set by setting max_mem. Alternatively, the proportion of the available memory may be set by setting max_mem_proportion (this should be a value between 0 and 1). Setting too low a value will result in excessive flushing, and very slow indexing. Setting too high a value will result in excessive buffering, leading to swapping, and very slow indexing. A reasonable default for max_mem_proportion for a system which is dedicated to indexing is probably 0.5: if other tasks are also being performed on the system, the value should be lowered. |
Add an action to be performed on a field. Note that this change to the configuration will not be preserved on disk until the next call to flush(). |
Clear all actions for the specified field. This does not report an error if there are already no actions for the specified field. Note that this change to the configuration will not be preserved on disk until the next call to flush(). |
Process an UnprocessedDocument with the settings in this database. The resulting ProcessedDocument is returned. Note that this processing will be automatically performed if an UnprocessedDocument is supplied to the add() or replace() methods of IndexerConnection. This method is exposed to allow the processing to be performed separately, which may be desirable if you wish to manually modify the processed document before adding it to the database, or if you want to split processing of documents from adding documents to the database for performance reasons. |
Add a new document to the search engine index. If the document has a id set, and the id already exists in the database, an exception will be raised. Use the replace() method instead if you wish to overwrite documents. Returns the id of the newly added document (making up a new unique ID if no id was set). The supplied document may be an instance of UnprocessedDocument, or an instance of ProcessedDocument. |
Replace a document in the search engine index. If the document does not have a id set, an exception will be raised. If the document has a id set, and the id does not already exist in the database, this method will have the same effect as add(). |
Add a synonym to the index.
|
Remove a synonym from the index.
|
Remove all synonyms for a word (or phrase).
|
Add a subfacet-facet relationship to the facet hierarchy. Any existing relationship for that subfacet is replaced. Raises a KeyError if either facet or subfacet is not a field, and an IndexerError if either facet or subfacet is not a facet field. |
Set the association between a query type and a facet. The value of |
Get the set of facets associated with a query type. Only those facets associated with the query type in the specified
manner are returned; If the query type has no facets associated with it, None is returned. |
Set an item of metadata stored in the connection. The value supplied will be returned by subsequent calls to get_metadata() which use the same key. Keys with a leading underscore are reserved for internal use - you should not use such keys unless you really know what you are doing. This will store the value supplied in the database. It will not be visible to readers (ie, search connections) until after the next flush. The key is limited to about 200 characters (the same length as a term is limited to). The value can be several megabytes in size. To remove an item of metadata, simply call this with a |
Get an item of metadata stored in the connection. This returns a value stored by a previous call to set_metadata. If the value is not found, this will return the empty string. |
Delete a document from the search engine index. If the id does not already exist in the database, this method will have no effect (and will not report an error). |
Apply recent changes to the database. If an exception occurs, any changes since the last call to flush() may be lost. |
Close the connection to the database. It is important to call this method before allowing the class to be garbage collected, because it will ensure that any un-flushed changes will be flushed. It also ensures that the connection is cleaned up promptly. No other methods may be called on the connection after this has been called. (It is permissible to call close() multiple times, but only the first call will have any effect.) If an exception occurs, the database will be closed, but changes since the last call to flush may be lost. |
Count the number of documents in the database. This count will include documents which have been added or removed but not yet flushed(). |
Get an iterator which returns all the ids in the database. The unqiue_ids are currently returned in binary lexicographical sort order, but this should not be relied on. |
Get the document with the specified unique ID. Raises a KeyError if there is no such document. Otherwise, it returns a ProcessedDocument. |
Get an iterator over the synonyms.
The iterator returns 2-tuples, in which the first item is the key (ie, a 2-tuple holding the term or terms which will be synonym expanded, followed by the fieldname specified (or None if no fieldname)), and the second item is a tuple of strings holding the synonyms for the first item. These return values are suitable for the dict() builtin, so you can write things like: >>> conn = IndexerConnection('foo') >>> conn.add_synonym('foo', 'bar') >>> conn.add_synonym('foo bar', 'baz') >>> conn.add_synonym('foo bar', 'foo baz') >>> dict(conn.iter_synonyms()) {('foo', None): ('bar',), ('foo bar', None): ('baz', 'foo baz')} |
Get an iterator over the facet hierarchy. The iterator returns 2-tuples, in which the first item is the subfacet and the second item is its parent facet. The return values are suitable for the dict() builtin, for example: >>> conn = IndexerConnection('db') >>> conn.add_field_action('foo', FieldActions.FACET) >>> conn.add_field_action('bar', FieldActions.FACET) >>> conn.add_field_action('baz', FieldActions.FACET) >>> conn.add_subfacet('foo', 'bar') >>> conn.add_subfacet('baz', 'bar') >>> dict(conn.iter_subfacets()) {'foo': 'bar', 'baz': 'bar'} |
Get an iterator over query types and their associated facets. Only facets associated with the query types in the specified manner
are returned; The iterator returns 2-tuples, in which the first item is the query type and the second item is the associated set of facets. The return values are suitable for the dict() builtin, for example: >>> conn = IndexerConnection('db') >>> conn.add_field_action('foo', FieldActions.FACET) >>> conn.add_field_action('bar', FieldActions.FACET) >>> conn.add_field_action('baz', FieldActions.FACET) >>> conn.set_facet_for_query_type('type1', 'foo', conn.FacetQueryType_Preferred) >>> conn.set_facet_for_query_type('type1', 'bar', conn.FacetQueryType_Never) >>> conn.set_facet_for_query_type('type1', 'baz', conn.FacetQueryType_Never) >>> conn.set_facet_for_query_type('type2', 'bar', conn.FacetQueryType_Preferred) >>> dict(conn.iter_facet_query_types(conn.FacetQueryType_Preferred)) {'type1': set(['foo']), 'type2': set(['bar'])} >>> dict(conn.iter_facet_query_types(conn.FacetQueryType_Never)) {'type1': set(['bar', 'baz'])} |
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0beta1 on Tue Apr 29 09:21:55 2008 | http://epydoc.sourceforge.net |